#33167 [Fbk]: pg_fetch_array can cause a segfault
| From: | tony2001@php.net | Date: | Fri, 27 May 2005 23:07:22 +0000 |
| Subject: | #33167 [Fbk]: pg_fetch_array can cause a segfault | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-79628@lists.php.net to get a copy of this message | ||
ID: 33167
Updated by: tony2001@php.net
Reported By: jsnell at networkninja dot com
Status: Feedback
Bug Type: PostgreSQL related
Operating System: Debian (dotdeb), gentoo
PHP Version: 5.0.4
New Comment:
Also, try it with the latest snapshot available at http://snaps.php.net
Previous Comments:
------------------------------------------------------------------------
[2005-05-28 01:05:42] tony2001@php.net
Please compile PHP with --enable-debug and generate GDB backtrace once
more.
------------------------------------------------------------------------
[2005-05-28 00:59:29] jsnell at networkninja dot com
Description:
------------
Calling pg_fetch_array() with the results of a division followed by
calling it with a constant causes a segfault. I have confirmed it in
both cgi and mod php 5.0.4 and also in cgi php 5.0.3.
Reproduce code:
---------------
// need a valid database to connect to
// contents don't matter
$query = 'select 1 as one';
$db_user = "your_user";
$db_password = "your_pass";
$db_name = "your_db";
$db_port = 5432;
$connect_string = "user=$db_user " .
"password=$db_password " .
"port=$db_port ".
"dbname=$db_name";
$db_link = pg_connect($connect_string);
$result = pg_exec($db_link, $query);
$i = floor(4/5);
$data = pg_fetch_array($result, $i);
$i = 0;
$data = pg_fetch_array($result, $i);
echo("No segfault");
Expected result:
----------------
No segfault
Actual result:
--------------
gdb backtrace:
#0 0x0820cf3b in _zend_hash_index_update_or_next_insert ()
#1 0x08209c53 in add_index_stringl ()
#2 0x406bee43 in zif_pg_fetch_result () from
/usr/lib/php5/20041030/pgsql.so
#3 0x406bf10f in zif_pg_fetch_array () from
/usr/lib/php5/20041030/pgsql.so
#4 0x0823c4da in zend_do_fcall_common_helper ()
#5 0x0823cb11 in zend_do_fcall_handler ()
#6 0x08224cb5 in execute ()
#7 0x08207e28 in zend_execute_scripts ()
#8 0x081d8bca in php_execute_script ()
#9 0x0824c3f4 in main ()
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=33167&edit=1