Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2006-07-24
20:43 • Closed ticket [1518166fff]: Possible un-Init'd DString in latest tclWinSock.... artifact: ffe6eb3ff3 user: dgp
20:42 • Ticket [1518166fff]: 4 changes artifact: 308582fb68 user: dgp
17:11 • Ticket [1518166fff]: 4 changes artifact: 7a668d42a9 user: afredd
2006-07-11
03:12 • Ticket [1518166fff]: 5 changes artifact: ca0a13bc4b user: dgp
2006-07-10
22:36 • Ticket [1518166fff]: 2 changes artifact: b289a3b3bb user: dgp
2006-07-06
14:01 • New ticket [1518166fff]. artifact: 17abf9a05e user: afredd

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.