|
2001-04-20
| ||
| 02:00 | • Ticket [218382ffff] FormatClock() mis-handles strftime() retrun status still... artifact: 9fafa5610e user: dgp | |
|
2000-10-26
| ||
| 08:21 | • Closed ticket [218382ffff]. artifact: e6b422dd67 user: welch | |
| 00:56 | • New ticket [218382ffff]. artifact: 2cd8cd4a38 user: nobody | |
FormatClock() mis-handles strftime() retrun
Closed / Fixed218382ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 00:56:55
OriginalBugID: 4404 Bug
Version: 8.3
SubmitDate: '2000-03-20'
LastModified: '2000-03-27'
Severity: SER
Status: Closed
Submitter: techsupp
ChangedBy: hobbs
OS: All Unix
OSVersion: not OS version specific
FixedDate: '2000-10-25'
ClosedDate: '2000-03-27'
Name:
Huver Hu
ReproducibleScript:
On nearly all Unices, strftime() is documented that "when it returns zero,
the buffer content is indeterminate". FormatClock() does not deal with
this properly.
DesiredBehavior:
see short diff attached.
Patch:
*** tclClock.c.old Tue Jan 25 21:37:40 2000
--- tclClock.c Mon Mar 20 00:49:37 2000
***************
*** 340,349 ****
tzset();
}
#endif
! if ((result == 0) && (*format != '\0')) {
! Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
"bad format string \"", format, "\"", (char *) NULL);
! return TCL_ERROR;
}
Tcl_SetStringObj(Tcl_GetObjResult(interp), buffer.string, -1);
--- 340,354 ----
tzset();
}
#endif
! if (result == 0) {
! /* if strftime() returns 0, the buffer content is indeterminate */
! if (*format != '\0') {
! Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
"bad format string \"", format, "\"", (char *) NULL);
! Tcl_DStringFree(&buffer);
! return TCL_ERROR;
! }
! Tcl_DStringSetLength(&buffer, 0);
}
Tcl_SetStringObj(Tcl_GetObjResult(interp), buffer.string, -1);
PatchFiles:
generic/tclClock.c
The current code is actually correct, because strftime actually
returns the number of chars written, and that will be zero when
format is "". The check for empty format was moved up though,
to avoid the extra code.
-- 03/27/2000 hobbs
welch Closed ticket [218382ffff].
[History diff]2000-10-26 08:21:16
dgp Ticket [218382ffff]: 3 changes
[History diff]2001-04-20 02:00:08
Log in (anonymous is fine) to add a comment.