Bad 2nd arg to pcre_replace causes SIGSEGV when /e

From: Date: Fri, 05 May 2000 16:07:37 +0000
Subject: Bad 2nd arg to pcre_replace causes SIGSEGV when /e
Groups: php.version4 
Request: Send a blank email to php-version4+get-14529@lists.php.net to get a copy of this message
This is from CVS, ~8 am this morning (-0700). Short desc. is that preg_replace is causing a SIGSEGV when I miss a quote mark in the 2nd arg and use /e. Not sure if this is PHP or PCRE. If it's PCRE, not much we can do about it, otherwise I'll log a bug. Input: <?xml version="1.0" encoding="UTF-8" standalone="no"?> Command being run: preg_replace("/(<)([^>]*)(>)/e", "'\\1FOO\\3", $line); Note the missing ' in the replace statement. This causes a SIGSEGV. Backtrace follows: <b>Parse error</b>: parse error in <b>Unknown</b> on line <b>0</b><br> Failed executing: '<FOO> Program received signal SIGSEGV, Segmentation fault. 0x2ae3acb9 in memcpy () from /lib/libc.so.6 (gdb) bt #0 0x2ae3acb9 in memcpy () from /lib/libc.so.6 #1 0x80a27e2 in _estrndup (s=0x0, length=135156420, __zend_filename=0x8196796 "php_pcre.c", __zend_lineno=592, __zend_orig_filename=0x0, __zend_orig_lineno=0) at zend_alloc.c:285 #2 0x80e5127 in _preg_do_eval (eval_str=0x825dfa4 "'\\1FOO\\3", subject=0x825e014 "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n", offsets=0x825dc94, count=4, result=0x7ffff458) at php_pcre.c:592 #3 0x80e537d in _php_pcre_replace (regex=0x825df2c "/(<)([^>]*)(>)/e", subject=0x825e014 "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n", replace=0x825dfa4 "'\\1FOO\\3") at php_pcre.c:679 #4 0x80e592e in _php_replace_in_subject (regex=0x825def4, replace=0x825df6c, subject=0x82486cc) at php_pcre.c:836 #5 0x80e5d81 in php_if_preg_replace (ht=3, return_value=0x825debc, this_ptr=0x0, return_value_used=0) at php_pcre.c:901 #6 0x8116af6 in execute (op_array=0x824b95c) at ./zend_execute.c:1573 #7 0x809b522 in php_execute_script (primary_file=0x7ffff9c4) at main.c:1178 #8 0x806da4d in main (argc=3, argv=0x7ffff9f4) at cgi_main.c:641 --Joey Smith Please forgive the long sig: *** Notice To Bulk Emailers: Attention! Pursuant to US Code, Title 47, Chapter 5, Subchapter II, 227, any & all unsolicited commercial e-mail sent to this address is subject to a download and archival fee in the amount of the $1500 US and copies will be forwarded to domain administrators. Emailing denotes acceptance of said terms!

« previous php.version4 (#14529) next »