php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45146 unixODBC (PDO) queries are causing segmentation error
Submitted: 2008-06-01 22:22 UTC Modified: 2008-06-02 18:39 UTC
From: csa at dside dot dyndns dot org Assigned:
Status: Not a bug Package: PDO related
PHP Version: 5.2.6 OS: Gentoo Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: csa at dside dot dyndns dot org
New email:
PHP Version: OS:

 

 [2008-06-01 22:22 UTC] csa at dside dot dyndns dot org
Description:
------------
ODBC (PDO) queries are causing segmentation error on 64 bit platforms under certain conditions if unixODBC is used to provide ODBC interface. The actual problem is definition of 'pdo_odbc_column' structure (in ext/pdo_odbc/php_pdo_odbc_int.h). The 'fetched_len' member is defined 'long'. However, in odbc_stmt.c (odbc_stmt_describe) the pointer on this member is passed as argument to SQLBindCol (ODBC library) which expects pointer on SQLINTEGER instead. On 64bit platforms unixODBC defines the 'SQLINTEGER' as 'int ' (a 32 bit number) and 'long' is a 64 bit number. 

On x86_64 this does not cause problems while negative numbers are not used. Therefore, the bug is rarely introduces itself. Unfortunately, in  the cases of NULL valued-columns it is possible  what '-1' is stored in this member variable. In this case the PhP while end up with segmentation fault.

I don't have access to formal ODBC specification and, therefore,don't really know if unixODBC correct in its implementation or violates specification. [ MS defines SQLINTEGER as 'long int'. But 'long int' on win64 is 32bit number. In Linux, 'long int' is 64bit and 'int' is 32bit ]. However, in either case the fix is very simple and will save php developers from lot headache. 

The proposed patch is available here:
http://dside.dyndns.org/projects/patches.dir/php-ds-odbc64.patch



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-06-02 18:39 UTC] csa at dside dot dyndns dot org
Things turned out to been even more complicated :( The problem is fixed in current CVS version of unixODBC.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jan 15 08:01:29 2025 UTC