Bug #68014 [NEW]: Result data values can be truncated because of incorrect column display sizes

From: Date: Fri, 12 Sep 2014 20:16:41 +0000
Subject: Bug #68014 [NEW]: Result data values can be truncated because of incorrect column display sizes
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-187528@lists.php.net to get a copy of this message
From: marcus dot england at noaa dot gov Operating system: All PHP version: 5.4.32 Package: ODBC related Bug Type: Bug Bug description:Result data values can be truncated because of incorrect column display sizes Description: ------------ The FieldIdentifier is being incorrectly set in the call to SQLColAttributes within the odbc_bindcols function in the ext/odbc/php_odbc.c file. Bug was introduced in version 5.4.32 and is present in all subsequent versions. In the column FOR loop, if the field identifier variable (colfieldid) is changed from SQL_COLUMN_DISPLAY_SIZE to SQL_DESC_OCTET_LENGTH for a SQL_CHAR, SQL_VARCHAR, SQL_WCHAR, or SQL_WVARCHAR column type, it will remain that way for any remaining columns in the table regardless of type. This causes SQLColAttributes to be called with the wrong identifier which returns an incorrect display size. In the case of a table with TINYINTs, this causes the displaysize to be incorrectly set to 1 rather than 3, resulting in too little memory being allocated for the result value, truncating the data. Test script: --------------- I tested with a table of tinyint's and varchar(20)'s with SQL Server and FreeTDS. tinyint columns that follow a varchar are incorrectly set to displaysize of 1 resulting in a truncation of the data, e.g. 85 becomes an 8. The displaysize should be 3. Expected result: ---------------- If we reset the FieldIdentifier to SQL_COLUMN_DISPLAY_SIZE for each iteration of the column loop, the bug is fixed. -- Edit bug report at https://bugs.php.net/bug.php?id=68014&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=68014&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=68014&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=68014&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=68014&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=68014&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=68014&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=68014&r=needscript Try newer version: https://bugs.php.net/fix.php?id=68014&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=68014&r=support Expected behavior: https://bugs.php.net/fix.php?id=68014&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=68014&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=68014&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=68014&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=68014&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=68014&r=dst IIS Stability: https://bugs.php.net/fix.php?id=68014&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=68014&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=68014&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=68014&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=68014&r=mysqlcfg

« previous php.bugs (#187528) next »