From: [email protected]
Operating system: Linux x86
PHP version: 5.3CVS-2009-07-02 (CVS)
PHP Bug Type: Reproducible crash
Bug description: parse_ini_file() crash with INI_SCANNER_RAW
Description:
------------
parse_ini_file() crashes in INI_SCANNER_RAW mode if a configuration item
consists solely of an equals sign.
Reproduce code:
---------------
INI file contents:
equal = "="
PHP script:
$ini = parse_ini_file('equals.ini', false, INI_SCANNER_NORMAL);
var_dump($ini);
$ini = parse_ini_file('equals.ini', false, INI_SCANNER_RAW);
var_dump($ini);
Expected result:
----------------
array(1) {
["equal"]=>
string(1) "="
}
array(1) {
["equal"]=>
string(1) "="
}
Actual result:
--------------
array(1) {
["equal"]=>
string(1) "="
}
Segmentation fault (core dumped)
gdb backtrace:
#0 0xb75f58b1 in memcpy () from /lib/tls/i686/cmov/libc.so.6
#1 0x083d5e5b in zend_strndup (s=0xb7f14009 <Address 0xb7f14009 out of
bounds>, length=3086171320) at /usr/include/bits/string3.h:52
#2 0x083d1b21 in ini_lex (ini_lval=0xbf9321d8) at
Zend/zend_ini_scanner.l:343
#3 0x083cf9fe in ini_parse () at
/h/aharvey/trees/php5/Zend/zend_ini_parser.c:1557
#4 0x083cfe91 in zend_parse_ini_file (fh=0xbf9322d0, unbuffered_errors=0
'\0', scanner_mode=1, ini_parser_cb=0x8320f20 <php_simple_ini_parser_cb>,
arg=0xa29d148) at /h/aharvey/trees/php5/Zend/zend_ini_parser.y:206
#5 0x0831f829 in zif_parse_ini_file (ht=3, return_value=0xa29d148,
return_value_ptr=0x0, this_ptr=0x0, return_value_used=1) at
/h/aharvey/trees/php5/ext/standard/basic_functions.c:5937
#6 0x08412a12 in execute_internal (execute_data_ptr=0xa2cddd8,
return_value_used=1) at /h/aharvey/trees/php5/Zend/zend_execute.c:1256
#7 0xb728dab0 in xdebug_execute_internal (current_execute_data=0xa2cddd8,
return_value_used=1) at /tmp/pear/temp/xdebug/xdebug.c:1630
#8 0x0843c9af in zend_do_fcall_common_helper_SPEC
(execute_data=0xa2cddd8) at
/h/aharvey/trees/php5/Zend/zend_vm_execute.h:315
#9 0x0841a08e in execute (op_array=0xa29c554) at
/h/aharvey/trees/php5/Zend/zend_vm_execute.h:104
#10 0xb728d734 in xdebug_execute (op_array=0xa29c554) at
/tmp/pear/temp/xdebug/xdebug.c:1561
#11 0x083f12f6 in zend_execute_scripts (type=8, retval=0x0, file_count=3)
at /h/aharvey/trees/php5/Zend/zend.c:1188
#12 0x0839f610 in php_execute_script (primary_file=0xbf9348f4) at
/h/aharvey/trees/php5/main/main.c:2196
#13 0x08476002 in main (argc=2, argv=0xbf934a54) at
/h/aharvey/trees/php5/sapi/cli/php_cli.c:1188
--
Edit bug report at http://bugs.php.net/?id=48768&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=48768&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=48768&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=48768&r=trysnapshot60
Fixed in CVS:
http://bugs.php.net/fix.php?id=48768&r=fixedcvs
Fixed in CVS and need be documented:
http://bugs.php.net/fix.php?id=48768&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=48768&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=48768&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=48768&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=48768&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=48768&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=48768&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=48768&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=48768&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=48768&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48768&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=48768&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=48768&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=48768&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=48768&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=48768&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=48768&r=mysqlcfg