Skip to Content.
Sympa Menu

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

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Dave Cole <djc AT object-craft.com.au>
  • To: freetds AT franklin.oit.unc.edu
  • Subject: off-by-one bug in tds_convert_any() causes segfault
  • Date: 01 Jan 2002 23:32:20 +1100


While trying to get my Python bindings for Sybase going with FreeTDS I
traced a segfault problem to an off-by-one error. The following patch
fixes the problem.

Everything seems to work now (with my Python bindings) but I want to
do some more work on the Python code before release later this week.

- Dave

--- freetds/src/tds/convert.c Mon Dec 3 11:06:14 2001
+++ freetds-new/src/tds/convert.c Tue Jan 1 23:20:41 2002
@@ -666,7 +666,7 @@
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 && strlen(any->c)>dlen) {
+ if (dlen && strlen(any->c)>=dlen) {
strncpy(dest,any->c,dlen-1);
dest[dlen-1]='\0';
for (i=strlen(dest)-1;dest[i]==' ';i--)

--
http://www.object-craft.com.au





Archive powered by MHonArc 2.6.24.

Top of Page