Overview
| Artifact ID: | 2cd8cd4a38a0ff27808307edab82d0003777c7f7 |
|---|---|
| Ticket: | 218382ffffffffffffffffffffffffffffffffff
FormatClock() mis-handles strftime() retrun |
| User & Date: | nobody on 2000-10-26 00:56:55 |
Changes
- assignee changed to: "nobody"
- cmimetype changed to: "text/plain"
- comment changed to:
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 - foundin changed to: "obsolete: 8.3"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- status changed to: "Open"
- submitter changed to: "nobody"
- subsystem changed to: "69. Other"
- title changed to: "FormatClock() mis-handles strftime() retrun"
- type changed to: "Bug"