From:             bl at btn dot de
Operating system: Red Hat Linux
PHP version:      4.3.2
PHP Bug Type:     ODBC related
Bug description:  odbc_errormsg() sometimes returns a bad string when no error occurs

Description:
------------
We use the IBMDB2 database on our systems. The following bug occured while
writing a class supposed to halt the code on database exceptions. 

While checking for strlen(odbc_errormsg())==0 for aborting the routine PHP
sometimes (about once in four calls) returns Bad Strings (see below).

Maybe the "message" is taken from an unallocated space on PHP's heap ?!?

It's not that much of a problem to come up with a workaround but PHP
shouldn't return random bits of the memory.



Reproduce code:
---------------
$link = odbc_connect("mydb", "myusr","mypwd");
$sql = "[INSERT FLAWLESS STATEMENT HERE]";
odbc_exec($link,$sql)
if(strlen(odbc_errormsg())>0) {
    echo "SQL-Error " . odbc_errormsg();
}
odbc_close($link);



Expected result:
----------------
If $sql contains a valid statement odbc_errormsg() should return an empty
string (according to the PHP-Documentation)

Actual result:
--------------
Sometimes parts of the outstream, a URL, short binary data, PHP-Variable
names anything might happen ... as I mentioned above, the data might be
part of PHP's heap. Some Examples:

T_URI (?) or

(a variable name ?)

ze:12px; } .menue_common{ [... here it goes on for quite a while ...]
width: 140px; margin-bottom: 2p 

(part of our stylesheet) or

ÿÿ or

(junk)

Àò or

(more junk)

aten_I or

(I have that somewhere earlier but I can't remember)

-urlencoded

(this shouldn't be an errormsg)


-- 
Edit bug report at http://bugs.php.net/?id=24244&edit=1
-- 
Try a CVS snapshot:         http://bugs.php.net/fix.php?id=24244&r=trysnapshot
Fixed in CVS:               http://bugs.php.net/fix.php?id=24244&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=24244&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=24244&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=24244&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=24244&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=24244&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=24244&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=24244&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=24244&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=24244&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=24244&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=24244&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=24244&r=gnused

Reply via email to