[PHP-BUG] Bug #55703 [NEW]: PHP crash when calling mysqli_fetch_fields
From: Operating system: Linux Ubuntu 11.04 PHP version: 5.3.8 Package: MySQLi related Bug Type: Bug Bug description:PHP crash when calling mysqli_fetch_fields Description: Hi, Running the attached test script causes a crash in mysqli extension (in every run). The crash comes from mysqli_api.c, at around line 1058: add_property_string(value, "catalog", (field->catalog ? field->catalog : ""), 1); The member field->catalog contains an address to an uninitialized pointer. Debugging libmysqlclient (self compiled, v5.1.58) shows that libmysqlclient simply left this member uninitialized, thus pointing to an uninitialized memory. To work around this bug, I modified my PHP sources locally so the "catalog" value is always set to "def" (which according to the documentation http://dev.mysql.com/doc/refman/5.0/en/c-api-data-structures.html is always true) (I also had a patch for libmysqlclient, but I am not sure where to send it...) This crash is reproducible in CLI mode using the test script attached. Attached is the patch to mysqli extension as well. Test script: --- https://bugs.php.net/bug.php?id=55703&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=55703&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=55703&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=55703&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=55703&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=55703&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=55703&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=55703&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=55703&r=needscript Try newer version: https://bugs.php.net/fix.php?id=55703&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=55703&r=support Expected behavior: https://bugs.php.net/fix.php?id=55703&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=55703&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=55703&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=55703&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=55703&r=php4 Daylight Savings:https://bugs.php.net/fix.php?id=55703&r=dst IIS Stability: https://bugs.php.net/fix.php?id=55703&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=55703&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=55703&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=55703&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=55703&r=mysqlcfg
Bug #55703 [Dup]: PHP crash when calling mysqli_fetch_fields
Edit report at https://bugs.php.net/bug.php?id=55703&edit=1 ID: 55703 User updated by:eran at zend dot com Reported by:eran at zend dot com Summary:PHP crash when calling mysqli_fetch_fields Status: Duplicate Type: Bug Package:MySQLi related Operating System: Linux Ubuntu 11.04 PHP Version:5.3.8 Block user comment: N Private report: N New Comment: Agreed. Same crash as #55662 Can you apply the attached patch? The patch simply avoids accessing the uninitialized pointer and sets the value to "def" (which like I mentioned in my previous post, is always the correct value, see here: http://dev.mysql.com/doc/refman/5.0/en/c-api-data-structures.html) Previous Comments: [2011-09-16 08:51:07] larue...@php.net plz look at #55662. anyway seems not only "explain" statement cause this segfault ---- [2011-09-15 15:12:16] eran at zend dot com Description: Hi, Running the attached test script causes a crash in mysqli extension (in every run). The crash comes from mysqli_api.c, at around line 1058: add_property_string(value, "catalog", (field->catalog ? field->catalog : ""), 1); The member field->catalog contains an address to an uninitialized pointer. Debugging libmysqlclient (self compiled, v5.1.58) shows that libmysqlclient simply left this member uninitialized, thus pointing to an uninitialized memory. To work around this bug, I modified my PHP sources locally so the "catalog" value is always set to "def" (which according to the documentation http://dev.mysql.com/doc/refman/5.0/en/c-api-data-structures.html is always true) (I also had a patch for libmysqlclient, but I am not sure where to send it...) This crash is reproducible in CLI mode using the test script attached. Attached is the patch to mysqli extension as well. Test script: --- https://bugs.php.net/bug.php?id=55703&edit=1