Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AE - Retrieving a negative decimal value (edge case) as output parameter causes truncation #705

Closed
lilgreenbird opened this issue Mar 6, 2018 · 2 comments

Comments

@lilgreenbird
Copy link
Contributor

lilgreenbird commented Mar 6, 2018

To reproduce:

  1. Connect with ColumnEncryption = Enabled
  2. Create an integer column with encryption (doesn't matter whether it's deterministic / randomized)
  3. Insert -2147483647 into this table
  4. Create a stored procedure to return this value as an OUTPUT parameter
  5. Call this stored procedure to retrieve this as a string (PDO::PARAM_STR) with length = 2048
  6. Error message "SQLSTATE[22003]: [Microsoft][ODBC Driver 17 for SQL Server]Numeric value out of range"

With AE, the integer column size is 10, and the buffer size required for "-2147483647" is 11.

This applies to negative decimals / numerics as well, using either SQLSRV or PDO_SQLSRV.
For example, if a column is of type decimal(4, 0), and the input is -9223.3720368548, the output param value is '-922'.

With SQLSRV, this might result in the error: "[Microsoft][ODBC Driver 17 for SQL Server]String data, right truncation"

See the new tests
sqlsrv_ae_output_param_sqltype_decimal_precision.phpt
sqlsrv_ae_output_param_sqltype_numeric.phpt
pdo_ae_output_param_integers.phpt
pdo_ae_output_param_decimals.phpt
for more examples.

@lilgreenbird
Copy link
Contributor Author

also note sqlsrv_ae_output_param_sqltype_numeric.phpt test for decimal(18,5) is also wrong not just truncated (fetched data has an "8"):

048+ c_det: -9223372036854.8008
049+ c_rand: 9223372036854.80080
048- c_det: -9223372036854.80000
049- c_rand: 9223372036854.80000

@yitam
Copy link
Contributor

yitam commented May 30, 2018

Fixed in 5.2.1-preview.

@yitam yitam closed this as completed May 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants