Edit report at https://bugs.php.net/bug.php?id=55703&edit=1

 ID:                 55703
 Updated by:         [email protected]
 Reported by:        eran at zend dot com
 Summary:            PHP crash when calling mysqli_fetch_fields
-Status:             Open
+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:

plz look at #55662. anyway seems not only "explain" statement cause this 
segfault


Previous Comments:
------------------------------------------------------------------------
[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:
---------------
<?php
$host  = '127.0.0.1';
$user  = 'user';
$pass  = 'password';
$db    = 'mydb';
$port  = 3306;
$link = mysqli_init();
if (mysqli_real_connect($link, $host, $user, $pass, $db, $port)) {
        $stmt = mysqli_stmt_init($link);
        if(mysqli_stmt_prepare($stmt, "show processlist")) {
                $res     = mysqli_stmt_execute($stmt);
                $res_set = mysqli_stmt_result_metadata($stmt);
                var_dump ( $res_set );
                var_dump(mysqli_fetch_fields( $res_set ));
        }
}




------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=55703&edit=1

Reply via email to