Possible un-Init'd DString in latest tclWinSock.c
Closed / Fixed1518166fffffffffffffffffffffffffffffffffCreated 20 years agoUpdated 20 years ago
Descriptionplain2006-07-06 14:01:04
In the latest tclWinSock.c (1.54), in the function InitializeHostName there is a possible logic path in which the DString "ds" is not Init'd but then used & Free'd. Bad voodoo :-) (Also is the fact that one branch lower cases the hostname string and the other not of any signifcance?)
dgp Ticket [1518166fff]: 2 changes
[History diff]2006-07-10 22:36:36
dgpplain2006-07-11 03:12:29
Logged In: YES user_id=80530 Tcl_WinTCharToUtf() is documented to take an uninitialized Tcl_DString. Look like the init/free balance is correct to me. Looks like the code assumes the value returned by gethostname() is in lowercase. If there's reason to believe that assumption can fail, the Tcl_UtfToLower() call can be added to the lower branch. The same maintainers who could answer that definitively could supply the proper buffer size requested in the code comments.
afreddplain2006-07-24 17:11:50
Logged In: YES
user_id=1386588
>Look like the init/free balance is correct to me.
What if neither of the if or 'else if' expressions is true?
The code outline is:
Tcl_DString ds;
if ((*tclWinProcs->getComputerNameProc)(wbuf, &length) !=
0) {
/* Initialise ds */
} else if (TclpHasSockets(NULL) == TCL_OK) {
/* Initialise ds */
}
/* Use ds */
Tcl_DStringFree(&ds);
Are you assuming that one of the two test expressions
(in particular "TclpHasSockets(NULL)") will always
be true?
dgpplain2006-07-24 20:42:56
Logged In: YES user_id=80530 I see. Fix committed.
dgp Closed ticket [1518166fff].
[History diff]2006-07-24 20:43:42
Log in (anonymous is fine) to add a comment.