Skip to Content.
Sympa Menu

freetds - Re: Fix for VARBINARY

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Frediano Ziglio <freddyz77 AT tin.it>
  • To: TDS Development Group <freetds AT franklin.oit.unc.edu>
  • Subject: Re: Fix for VARBINARY
  • Date: 17 Nov 2002 19:05:02 +0100


Il dom, 2002-11-17 alle 18:32, James K. Lowden ha scritto:
> On 17 Nov 2002 11:07:15 +0100, Frediano Ziglio <freddyz77 AT tin.it> wrote:
> > This type had many problems:
> > - conversions to VARBINARY was unavailable
> > - unsupported VARBINARY > 255 (mssql7+)
> > (also a bad buffer overflow was spotted)
> > This was fixed saving VARBINARY in libtds in the same way of BINARY (a
> > simple array of bytes). This has some drawbacks:
> > - conversion to VARBINARY are trivial (the good one)
>
> All good!
>
> > - libraries should handle "conversion" from libtds VARBINARY to library
> > VARBINARY.
>
> Not clear to me. Could you point to the lines in convert.c, please?
>

The lack is not in convert.c but in client source
See this page (search for CS_VARBINARY). There is a binding type in
ctlib (that seem not supported by our library). It return a structure
CS_VARBINARY. Same lack for CS_VARCHAR. ODBC haven't this problem,
dblib.. I don't know... Also libtds do not handle this structure...
http://manuals.sybase.com/onlinebooks/group-cn/cng1250e/guide/@Generic__BookTextView/4041

> > It seem that dblib/ctlib do not return VARBINARY type.. quite
> > strange.
>
> Sybase db-lib documentation for dbcoltype:
>
> In a few cases, the token value returned by this routine may
> not correspond exactly with the column's server datatype:
> · SYBVARCHAR is returned as SYBCHAR.
> · SYBVARBINARY is returned as SYBBINARY.

Strange! Does our library have same behavior?

> · SYBDATETIMN is returned as SYBDATETIME.
> · SYBMONEYN is returned as SYBMONEY.
> · SYBFLTN is returned as SYBFLT8.
> · SYBINTN is returned as SYBINT1, SYBINT2, or SYBINT4,
> depending on the actual type of the SYBINTN.
>
> and dbconvert:
>
> 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".
>

Correct.

>
> Frediano, do you think this will help Paul Kiela? Were we lying about the
> length of a returned buffer? Not that that should result in a segfault in
> PHP.
>

I don't remember. PHP has a bug returning binary data. It call dbconvert
using same length of buffer (but dbconvert require double of space) and
pass buffer length as -1 (there is sufficient space). So lead to a
buffer overflow...

> Chris's data have no binary types. All numeric, char, and datetime
> AFAICT. I think I misled you; he *does* use numeric conversion. See my
> message to him on 14 November.
>

I think I should compile PHP... very strange... but problem raise after
numeric change... so...

bye
freddy77






Archive powered by MHonArc 2.6.24.

Top of Page