[freetds] Possible free(NULL) in tsql

ZIGLIO, Frediano, VF-IT Frediano.Ziglio at vodafone.com
Fri Oct 12 04:56:50 EDT 2007


Looking at recent changes at tsql.c
http://freetds.cvs.sourceforge.net/freetds/freetds/src/apps/tsql.c?r1=1.
107&r2=1.108&diff_format=l

if continue at line 711 is hit s2 == NULL and a free(s2) (line 690) is
executed. This can cause a core in some system. Perhaps we could undo
lines 717-718 removing free(s2) at line 690 or use a static buffer and
some code (strcpyn/strspn/other) to get cmd something like replacing
lines 717-723 with

cmd = s + strspn(s, " \t");
cmd_end = cmd + strcspn(cmd, " \t");
save = *cmd_end;
*cmd_end = 0;

and inserting a

*cmd_end = save;

before line 742

(char save; char *cmd_end;)

(I know, it's a fucking optimization!)

freddy77



More information about the FreeTDS mailing list