Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 2cd8cd4a38a0ff27808307edab82d0003777c7f7
Ticket: 218382ffffffffffffffffffffffffffffffffff
FormatClock() mis-handles strftime() retrun
User & Date: nobody on 2000-10-26 00:56:55
Changes

  1. assignee changed to: "nobody"
  2. cmimetype changed to: "text/plain"
  3. 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
    
  4. foundin changed to: "obsolete: 8.3"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "nobody"
  9. subsystem changed to: "69. Other"
  10. title changed to: "FormatClock() mis-handles strftime() retrun"
  11. type changed to: "Bug"