Skip to Content.
Sympa Menu

freetds - Re: off-by-one bug in tds_convert_any() causes segfault

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Bill Thompson" <thompbil AT exchange.uk.ml.com>
  • To: freetds AT franklin.oit.unc.edu
  • Subject: Re: off-by-one bug in tds_convert_any() causes segfault
  • Date: Wed, 2 Jan 2002 09:57:10 -0500


Hmmm...I had problems here too (in version 5.2).

I was also not happy with the way that conversions to strings were being
handled (in the area of string padding/null terminating), and have coded
the following :

...
switch(dtype) {
case SYBCHAR:
case SYBVARCHAR:
tdsdump_log(TDS_DBG_INFO1, "%L converting string dlen = %d
dtype = %d string = %s\n",dlen,dtype,any->c);
if (dlen > 0) {
if (strlen(any->c) > dlen ) {
strncpy(dest, any->c , dlen);
}
else {
strcpy(dest, any->c);
for ( i = strlen(dest); i < dlen; i++)
dest[i] = ' ';
}
ret = dlen;
}
if (dlen == -1 ) {
strcpy(dest, any->c);
for (i=strlen(dest)-1;dest[i]==' ';i--)
dest[i]='\0';
ret = strlen(dest);
}
if (dlen == -2 ) {
strcpy(dest, any->c);
ret = strlen(dest);
}
break;

case SYBTEXT:
....

This supports the destlen parameters of -1 & -2 as specified in the Sybase
dblib function dbconvert().

I have not submitted this change yet, as it is part of a much larger
enhancement I am working on...

regards,

Bill




Archive powered by MHonArc 2.6.24.

Top of Page