#44333 [Opn->Csd]: SEGFAULT when using mysql_pconnect() with client_flags
ID: 44333
Updated by: felipe@php.net
Reported By: drake at oomkill dot net
-Status: Open
+Status: Closed
Bug Type: Reproducible crash
Operating System: Hardened Gentoo Linux (amd64)
PHP Version: 5.2.6RC1
New Comment:
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2008-03-04 21:03:51] drake at oomkill dot net
Description:
------------
Segfaults appear when using:
mysql_pconnect('localhost', 'foo', 'bar', 0);
but runs fine when using:
mysql_pconnect('localhost', 'foo', 'bar');
The bug is most likely caused by trying to store a 'long' value in an
'int' on the stack.
At the beginning of php_mysql_do_connect() in ext/mysql/php_mysql.c
there is the following declaration:
int client_flags = 0;
Later in that function zend_parse_parameters() stores a long at
&client_flags, which can also overwrite another variable on the stack.
Changing the client_flags to unsigned long (like it is defined in
mysql's headers) solved my segfault problem.
Reproduce code:
---------------
// the user/pass don't have to be valid.
mysql_pconnect('localhost', 'foo', 'bar', 0);
Expected result:
----------------
No segfault.
Actual result:
--------------
Segfault. No php/zend error message in logs.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=44333&edit=1
Thread (2 messages)