#43861 [Com]: suhosin patch detects heap overflow on mssql_free_result()
| From: | cxcxcxcx at gmail dot com | Date: | Sun, 10 Feb 2008 07:57:04 +0000 |
| Subject: | #43861 [Com]: suhosin patch detects heap overflow on mssql_free_result() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-122145@lists.php.net to get a copy of this message | ||
ID: 43861
Comment by: cxcxcxcx at gmail dot com
Reported By: skennedy at vcn dot com
Status: Open
Bug Type: MSSQL related
Operating System: FreeBSD 6.2
PHP Version: 5.2.5
New Comment:
I have encountered a similar problem. When "select" contains
'smalldatetime' or 'datetime' columns.
I am using Debian Sid and php5 php5-sybase.
Previous Comments:
------------------------------------------------------------------------
[2008-01-31 00:16:10] rasmus@php.net
Ok, there we go. Looks like there is an off-by-one in there. But
looking at the PHP code, it seems ok.
int res_length = dbdatlen(mssql_ptr->link,offset);
...
res_buf = (unsigned char *) emalloc(res_length+1);
res_length =
dbconvert(NULL,coltype(offset),dbdata(mssql_ptr->link,offset),
res_length, SQLCHAR,res_buf,-1);
res_buf[res_length] = '\0';
So, we aren't going beyond the buffer, it is somewhere in the
dbconvert() code writing to res_buf that is off. Passing in a larger
buffer would fix it, but it would be good to understand why dbdatlen()
isn't returning the right length. Is it an encoding issue? One assumes
single-byte encoding and the other multi-byte or something?
Looping in Frank to have a look.
------------------------------------------------------------------------
[2008-01-30 21:23:02] skennedy at vcn dot com
Okay, here is that:
http://www.bandwidthbuilders.com/valgrind-output-nozendalloc.txt
------------------------------------------------------------------------
[2008-01-30 21:08:27] derick@php.net
Sometimes the Zend memory manager hides stuff as well. Could you please
try disabling that by setting the "USE_ZEND_ALLOC" environment variable
to 0? (Something like "export USE_ZEND_ALLOC=0" should do that). And
then re-try to make a valgrind trace. Thanks!
------------------------------------------------------------------------
[2008-01-30 18:38:10] skennedy at vcn dot com
That valgrind output *is* without the Suhosin patch.
I was saying that I first compiled PHP w/ Suhosin patch to make sure it
errors-out with the heap overflow as it does on my FreeBSD box and it
did. Then I compiled PHP again this time w/out Suhosin and ran the
valgrind which is the output you see in the link.
------------------------------------------------------------------------
[2008-01-30 17:56:21] rasmus@php.net
Again, that valgrind output does not show an overflow. Either the
problem is being masked by the suhosin patch, or it is a false positive.
Trying removing the suhosin patch and do the valgrind check again.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/43861
--
Edit this bug report at http://bugs.php.net/?id=43861&edit=1