Skip to Content.
Sympa Menu

freetds - Buggy use of sizeof in src/tds/config.c

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Craig Davison" <cd AT securityfocus.com>
  • To: freetds AT franklin.oit.unc.edu
  • Subject: Buggy use of sizeof in src/tds/config.c
  • Date: Tue, 25 Sep 2001 00:10:34 -0400


sizeof is used inappropriately on char pointers in a few places in
src/tds/config.c. sizeof(char *) will always return sizeof(void *) - that
is to say, 4 or 8 on most systems, and not the intended string length.

search_interface_file fails completely in freetds 0.52. It tries to open
files such as /ho and /et on my box (where sizeof(char *) is 4). Here is a
patch:


*** config.c Tue Jun 19 06:22:00 2001
--- config.c Mon Sep 24 22:01:49 2001
***************
*** 497,507 ****
}
else
{
! strncpy(pathname, dir, sizeof(pathname));
! strncat(pathname, "/", sizeof(pathname));
}
! strncat(pathname, file, sizeof(pathname));
! pathname[sizeof(pathname)-1] = '\0';
}


--- 497,507 ----
}
else
{
! strcpy(pathname, dir);
! strcat(pathname, "/");
}
! strcat(pathname, file);
! pathname[strlen(dir) + strlen(file) + 9] = '\0';
}


Thanks & keep up the good work!




Archive powered by MHonArc 2.6.24.

Top of Page