Skip to Content.
Sympa Menu

freetds - Re: [PHP4BETA] php4+freetds, off-by-1 truncation

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Brian Bruns <camber AT umcc.ais.org>
  • To: TDS Development Group <freetds AT franklin.oit.unc.edu>
  • Subject: Re: [PHP4BETA] php4+freetds, off-by-1 truncation
  • Date: Fri, 3 Dec 1999 20:17:00 -0500 (EST)



Ok, this one is fixed and in CVS. Or you can patch your local copy
thusly:

In src/tds/convert.c function tds_convert_any() change

return(strlen(dest));

to

return (strlen(dest)+1);

What happens is PHP uses length binding, which for strings should include
the null as well as the characters in the string. So, PHP cuts off what
it thinks in the NULL but is actually the last character. sqsh and
DBD::Sybase don't seem to rely on length binding and were uneffected by
this bug.

Brian

On Fri, 3 Dec 1999 richard AT iguana.co.nz wrote:

> > > > Hey people.
> > > >
> > > > We have php4 and freetds working correctly, and talking to the
> > > > database (Both versions are CVS from Tuesday) however we have a
> > > > slight problem with the sybase-ct module. Now before I go hacking
> > > > around, I thought I'd ask if anyone has a good idea why the
> > > > following would be happening:
> > > >
> > > > Strings are all too short by 1 char (final letter is always missing)
> > > > Row count is off on occasion.
> > > >
> > > > I don't believe these two are related particularly, so ideas on one or
> > > > both appreciated.
>
> A possibility was offered that it may be a conflict with other libraries,
> however we have no other libraries installed. Further details:
>
> The relevant box is a debian box (potato) with:
>
> - Freetds (tuesday CVS)
> - PHP4b3 (tuesday CVS) w gd and sybase-ct
> - Sybperl (Latest stable from CPAN)
> - SQSH (latest stable)
>
> Installed.
>
> SQSH and Sybperl are functioning 100% correctly, PHP is connecting
> correctly, and for the most part working, except for the following:
>
> Every string line recieved from a hash is one character short
>
> My conclusion from this is that for some reason the Sybase-ct module in
> PHP is setting the length wrong or similar.
>
> My previous note about invalid row counts I haven't been able to verify
> (however I have regards the one-char-short issue) so this may not be a
> problem.
>
> Richard.
>





Archive powered by MHonArc 2.6.24.

Top of Page