[freetds] [PATCH] Problem with VARCHAR in sybase.

James K. Lowden jklowden at freetds.org
Mon Jul 7 10:01:37 EDT 2008


Eddy Pronk wrote:
> > If datafmt->maxlength represents the size of an
> > allocated buffer, increasing it without reallocating will write the
> > NULL to unallocated memory, with predictable unpredictable [sic]
> > results.  
>   
> In dbd_freetds.c inside libdbi the allocation is done. I allocated 1byte
> 
> extra as well, so that is fine.
> 
> I've seen your recent changes. I would expect with your changes if I 
> remove the ++datafmt->maxlength; it would still work but it breaks.

No, I made some corrections, but the fundemental behavior was right: you
must provide room in the destination buffer for the terminating NULL.  If
you don't, ct_fetch will fail.  

I fixed what ct_fetch does before it fails. Previously, it wouldn't copy
anything if the destination buffer was too small.  Now it copies as much
as fits.  

> Are you willing to look at libdbi? 

I'm not really eager to do that.  I'm very willing to help you get it
right, though.  It sounds like the change you made is correct.  

> do you think it is possible to run the unittests on Solaris with 
> the Sybase libraries?

It is meant to be possible and shouldn't be too hard.  One of the things
I'd like to do is change the unit test machinery to make it easy to link
them to other libraries instead.  That would make inconsistent behavior
easier to find.  

Regards, 

--jkl



More information about the FreeTDS mailing list