Skip to Content.
Sympa Menu

freetds - Re: Fix for VARBINARY

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Franck Martin <Franck AT sopac.org>
  • To: 'TDS Development Group' <freetds AT franklin.oit.unc.edu>
  • Subject: Re: Fix for VARBINARY
  • Date: Mon, 18 Nov 2002 09:34:24 +1200


I have been playing with image type and varbinary for quite a while, and I
had to do workaround solution at the MS-SQL level.

I use freetds + php

I found out also that there is a recurring bug in PHP between buffer size
and number of characters for all n* types. PHP works in unicode and think
that the size is the number of characters and not the buffer size in bytes.
The result is that PHP reads too much and outputs fancy stuff...

As for the image types and so on, there are conversion happening which are
very strange...I think sometime the some characters below <32 gets
interpreted or discarded...

But I had some success:
http://www.sopac.org/Data/Aerial/Snaps.html?setid=227&pp=1

If you want me to help somehow, let me know...

This feature is very important for me, so I'm ready to help, but need
guidance...

if you search the archive you will find a couple of posts from me about this
subject...

Cheers.
Franck AT sopac.org

> -----Original Message-----
> From: Frediano Ziglio [mailto:freddyz77 AT tin.it]
> Sent: Monday, 18 November 2002 6:05
> To: TDS Development Group
> Subject: [freetds] Re: Fix for VARBINARY
>
>
> 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