php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53847 Crash after setting $field in mysql_result to NULL
Submitted: 2011-01-26 13:40 UTC Modified: 2011-08-20 18:03 UTC
From: ps at tns dot cz Assigned: kalle (profile)
Status: No Feedback Package: MySQL related
PHP Version: 5.3.5 OS: FreeBSD 8.1-RELEASE-p1 amd64
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2011-01-26 13:40 UTC] ps at tns dot cz
Description:
------------
Assigning of value NULL to $field argument of mysql_result causes segmentation fault.

PHP version: PHP 5.3.5 with Suhosin-Patch (cli) (built: Jan 10 2011 14:50:28)

Installed modules:
php5-ctype-5.3.5
php5-curl-5.3.5
php5-dom-5.3.5
php5-ftp-5.3.5
php5-gd-5.3.5
php5-hash-5.3.5
php5-iconv-5.3.5
php5-json-5.3.5
php5-mbstring-5.3.5
php5-mcrypt-5.3.5
php5-mysql-5.3.5
php5-mysqli-5.3.5
php5-openssl-5.3.5
php5-session-5.3.5
php5-simplexml-5.3.5
php5-soap-5.3.5
php5-tidy-5.3.5
php5-tokenizer-5.3.5
php5-xml-5.3.5
php5-zip-5.3.5
php5-zlib-5.3.5

Diff for php.ini:
http://pastebin.com/5D1WsneT


Test script:
---------------
http://pastebin.com/2D4mVyEx

Expected result:
----------------
Script should run and output nothing.

Actual result:
--------------
Segmentation fault. Problem is the wrong assigning of value NULL to $field argument of mysql_result on lines 13-14.

Weird is that commenting out one line of for example lines 31, 32 or 33 avoids the crash.

Cannot reproduce with Zend MM disabled.

Cannot reproduce with PHP compiled with debug option (!).

Backtrace (not useful since debug must be disabled) http://pastebin.com/KksuenGw

Valgrind log (I guess not useful eighter since debug must be disabled) http://pastebin.com/vu9nsLLT

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-01-30 11:07 UTC] kalle@php.net
-Status: Open +Status: Feedback -Package: Reproducible crash +Package: MySQL related
 [2011-01-30 11:07 UTC] kalle@php.net
Could you try without the Suhosin patch (as we don't supported patched versions), and does this happen when the mysql extension is linked specifically to libmysql or mysqlnd?
 [2011-01-30 11:18 UTC] kalle@php.net
-Assigned To: +Assigned To: kalle
 [2011-01-30 11:18 UTC] kalle@php.net
Looking at the source, this could be due to a similar crash in the fetching functions with int<->long on 64bit:

zif_mysql_result declares a variable called field_offset to 1. After the parameters is processed, the function will check the value of $field which will be cast to a long and put into the int variable: "field_offset = Z_LVAL_P(field);".

Try changing line 1880 of ext/mysql/php_mysql.c in the latest 5.3 source (from SVN) from 'int' to 'long'.
 [2011-08-20 18:03 UTC] kalle@php.net
-Status: Feedback +Status: No Feedback
 [2011-08-20 18:03 UTC] kalle@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 28 11:01:30 2024 UTC