Bug #68350 [Com]: SQL_DESC_OCTET_LENGTH not supported by ADS ODBC driver

From: Date: Wed, 15 Apr 2015 13:37:24 +0000
Subject: Bug #68350 [Com]: SQL_DESC_OCTET_LENGTH not supported by ADS ODBC driver
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-192099@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=68350&edit=1

 ID:                 68350
 Comment by:         frederic dot marchal at wowtechnology dot com
 Reported by:        frederic dot marchal at wowtechnology dot com
 Summary:            SQL_DESC_OCTET_LENGTH not supported by ADS ODBC
                     driver
 Status:             Open
 Type:               Bug
 Package:            ODBC related
 PHP Version:        5.4.34
 Block user comment: N
 Private report:     N

 New Comment:

The patch https://github.com/php/php-src/commit/b3a027d6103b69bb935431dbec2e59eb20454862
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.


Previous Comments:
------------------------------------------------------------------------
[2015-04-14 20:00:48] cmb@php.net

Might be related to bug #69354.

------------------------------------------------------------------------
[2015-04-11 17:55:46] cmb@php.net

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
help.

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

[1] <https://github.com/php/php-src/commit/df9078ea55e2bd60d718c6e6948b70311650fe39>

------------------------------------------------------------------------
[2015-04-11 17:21:49] frederic dot marchal at wowtechnology dot com

I assume this is the very last php_odbc.c file:

https://github.com/php/php-src/blob/master/ext/odbc/php_odbc.c

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 16:46:06] cmb@php.net

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?

------------------------------------------------------------------------
[2014-11-05 12:48:42] frederic dot marchal at wowtechnology dot com

Description:
------------
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 libadsodbc.so returns an invalid value when SQLColAttributes is
queried with SQL_DESC_OCTET_LENGTH.

It worked before this commit:

https://github.com/php/php-src/commit/7301994c28d548c5a4eda6a3a4ae0fab6af04636

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



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=68350&edit=1


Thread (10 messages)

« previous php.bugs (#192099) next »