Bug #70565 [Com]: PDO DBLIB MSSql Segmentaion Fault with Prepared Statements
| From: | reyad dot attiyat at gmail dot com | Date: | Wed, 23 Sep 2015 20:07:31 +0000 |
| Subject: | Bug #70565 [Com]: PDO DBLIB MSSql Segmentaion Fault with Prepared Statements | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-196194@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=70565&edit=1
ID: 70565
Comment by: reyad dot attiyat at gmail dot com
Reported by: reyad dot attiyat at gmail dot com
Summary: PDO DBLIB MSSql Segmentaion Fault with Prepared
Statements
Status: Open
Type: Bug
Package: PDO DBlib
Operating System: Windows 7
PHP Version: 7.0Git-2015-09-23 (Git)
Block user comment: N
Private report: N
New Comment:
Might be related to BUG #67495
Previous Comments:
------------------------------------------------------------------------
[2015-09-23 20:00:21] reyad dot attiyat at gmail dot com
Description:
------------
I'm using the latest version of PHP7 master from git compiled on Windows 7 with Visual Studios
2015. The database is MS SQL Server 2014.
I have compiled FreeTDS and the pdo_dblib support, which works fine except, after several executions
of a prepared insert statement (that may contain UTF-8 characters) a segmentation fault or corrupted
SQL query occurs.
The error seems to be only reproducible when sending UTF-8 characters.
After stepping through the application I have noticed in the file:
https://github.com/php/php-src/blob/master/ext/pdo_dblib/dblib_driver.c
in function:
dblib_handle_quoter()
The quoted string allocation uses emalloc(). This seems to randomly return a pointer to a previously
allocated quoted string. This has caused both corrupted queries and segmentation faults.
I checked out the code for the other pdo drivers and they use safe_emalloc() when allocating quoted
strings. When I changed the dblib_handle_quoter() function to use safe_emalloc() instead of
emalloc() the problem goes away.
Test Script:
https://gist.github.com/soda0289/d99fc7e82db8443c7058
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=70565&edit=1