0.60 + PHP + MSSQL2K segfault -- depends on the query (??)

Frediano Ziglio freddyz77 at tin.it
Fri May 2 19:13:14 EDT 2003


>                                                                                                           991105 thies at thieso.net  */
> 
>   dbconvert(NULL,coltype(offset),dbdata(sybase_ptr->link,offset),
> res_length,SYBCHAR,res_buf,-1);
> 
> Converting binary -> char PHP allocate only length+1 bytes of binary but
> conversion binary -> char require 2*length bytes (plus terminator), do
> it's a buffer overflow.
> So, or PHP is wrong and should allocate more space or FreeTDS dblib is
> wrong and conversion binary -> char should just do a memcpy instead of
> converting to hexadecimal...
> 
> freddy77
> 

>From Sybase docs:

A conversion to or from the datatypes SYBBINARY and SYBIMAGE is a
straight bit-copy, except when the conversion involves SYBCHAR or
SYBTEXT. When converting SYBCHAR or SYBTEXT data to SYBBINARY or
SYBIMAGE, DBCONVERT interprets the SYBCHAR or SYBTEXT string as
hexadecimal, whether or not the string contains a leading "0x". When
converting SYBBINARY or SYBIMAGE data to SYBCHAR or SYBTEXT, dbconvert
creates a hexadecimal string without a leading "0x".

So, is definitely a PHP bug !

freddy77





More information about the FreeTDS mailing list