|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68350 SQL_DESC_OCTET_LENGTH not supported by ADS ODBC driver
Submitted: 2014-11-05 12:48 UTC Modified: 2015-04-28 13:19 UTC
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: frederic dot marchal at wowtechnology dot com Assigned: ab (profile)
Status: Closed Package: ODBC related
PHP Version: 5.4.34 OS:
Private report: No CVE-ID: None
 [2014-11-05 12:48 UTC] frederic dot marchal at wowtechnology dot com
Running odbc_exec() on an ADS ODBC driver version 11.0 or 11.1 for Linux produces errors such as:

PHP Fatal error:  Out of memory (allocated 524288) (tried to allocate 12415340535808218625 bytes) in SybaseClass.php on line 127

The error is produced because returns an invalid value when SQLColAttributes is queried with SQL_DESC_OCTET_LENGTH.

It worked before this commit:

The patch simply checks the return value from SQLColAttributes and falls back on the old method to get the column size.


ads_odbc_exec.patch (last revision 2014-11-05 12:49 UTC by frederic dot marchal at wowtechnology dot com)

Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-04-11 16:46 UTC]
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2015-04-11 16:46 UTC]
I assume the actual reason for the misbehavior is bug #68087, which
has already been fixed in 5.5.19 and 5.6.3, but will not be fixed
for PHP 5.4.

Can you please confirm that?
 [2015-04-11 17:21 UTC] frederic dot marchal at wowtechnology dot com
I assume this is the very last php_odbc.c file:

Then, no, the problem isn't fixed. You can see, at line 994, that the return code rc is ignored. The problem I face is that the ODBC driver doesn't support SQL_DESC_OCTET_LENGTH. The ODBC driver rightfully returns an error code when PHP queries that attribute. As PHP doesn't check the return code it continues with the uninitialized displaysize and tries to emalloc a memory block with a size of whatever happen to be in displaysize. You can see the result in my initial report.

You should have a look at the patch I supplied. It has been included in Debian and, so far, it works fine.
 [2015-04-11 17:55 UTC]
Due to bug #68087 SQL_DESC_OCTET_LENGTH could have been applied for
other fields than SQL_*CHAR, which is likely to fail. The
respective fix[1] resolved this issue. For drivers not recognizing
SQL_DESC_OCTET_LENGTH for SQL_*CHAR fields, of course that wouldn't

I'm unassigning myself, so someone else with access to an ADS and
php-src karma can pick up.

[1] <>
 [2015-04-11 17:55 UTC]
-Assigned To: cmb +Assigned To:
 [2015-04-12 00:01 UTC]
-Status: Feedback +Status: Open
 [2015-04-14 20:00 UTC]
Might be related to bug #69354.
 [2015-04-15 13:37 UTC] frederic dot marchal at wowtechnology dot com
The patch solves the problem for the ADS ODBC driver too.

Simply replacing SQLColAttributes with SQLColAttribute (without 's') does the trick.

So, this bug is similar to bug #69354 and the solution proposed there is better than my patch as it addresses the cause of the problem instead of working around it.
 [2015-04-17 19:00 UTC]
@frederic, if it's fixed with #69354 as well - so that's great. The subsequent fixes to the ext/odbc in the 5.5 branch could be of some interest for you, as well. 

I think it's hardly going into 5.4 though, as it's more about ODBC 3.0 support and not security. So probably you've two ways - either upgrading to at least 5.5 or patching 5.4 manually. Anyway seems this ticket is done now, please close it by chance.

 [2015-04-19 07:58 UTC] frederic dot marchal at wowtechnology dot com
-Status: Open +Status: Closed
 [2015-04-19 07:58 UTC] frederic dot marchal at wowtechnology dot com
Problem adequately solved by bug #69354.
 [2015-04-28 13:19 UTC]
-Assigned To: +Assigned To: ab
 [2015-04-28 13:19 UTC]
@frederic FYI i've applied your patch (in master also added a warning)for the sake of compatibility. Seems the driver from the ticket #69381 has a real issue with this.

PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Tue Mar 21 18:03:39 2023 UTC