Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: cceb47b58bb1e2c18bf96d5bd88d8ecd28c89791
Ticket: 218905ffffffffffffffffffffffffffffffffff
Tcl_ReadChars is unsafe for stacked channels
User & Date: nobody on 2000-10-26 01:07:37
Changes

  1. assignee changed to: "nobody"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    OriginalBugID: 2623 Bug
    Version: 8.2
    SubmitDate: '1999-08-31'
    LastModified: '1999-11-18'
    Severity: CRIT
    Status: Released
    Submitter: techsupp
    ChangedBy: hobbs
    OS: Windows NT
    Machine: X86
    FixedDate: '1999-11-18'
    FixedInVersion: 8.2.1
    ClosedDate: '2000-10-25'
    
    
    Name:
    
    Matt Newman
    
    
    CustomShell:
    
    The above patch, plus the tclPosixStr.c patch plus a patch to fix the -translation and -eofchar bugs in GetOption code (to be submitted sortly)
    
    
    Comments:
    
    A low risk patch that urgently needs to be applied.
    
    
    ObservedBehavior:
    
    Tcl_ReadChars does not allocate a Tcl_Obj for its data, but instead uses
    
        the existing Tcl Result OBJ. This is normally relatively safe, but bad
    
        practice.
    
    
        How ever with stacked channels the underlying channel may issue
    
        Tcl_Eval's during the read processing, which causes a complex corruption
    
        of the Tcl_Obj that Tcl_ReadChars is using - and because of the way it
    
        works this almost *ALWAYS* will cause a core dump.
    
    
        This behaviour was first observed whilst testing the
    
        shortly-to-be-released TLS (aka SSL) extension - but the exposure exists
    
        for *ALL* stacked channels that may perform Tcl_Evals.
    
    
    DesiredBehavior:
    
    No bugs - no crashs.
    
    
    Patch:
    
    Index: tclIOCmd.c
    
    ===================================================================
    
    RCS file: /cvs/tcl/tcl8.2/generic/tclIOCmd.c,v
    
    retrieving revision 1.1.1.1
    
    diff -c -r1.1.1.1 tclIOCmd.c
    
    *** tclIOCmd.c  1999/08/19 12:32:00     1.1.1.1
    
    --- tclIOCmd.c  1999/08/23 16:59:41
    
    ***************
    
    *** 350,361 ****
    
              }
    
          }
    
    
    !     resultPtr = Tcl_GetObjResult(interp);
    
          charactersRead = Tcl_ReadChars(chan, resultPtr, toRead, 0);
    
          if (charactersRead < 0) {
    
            Tcl_ResetResult(interp);
    
            Tcl_AppendResult(interp, "error reading \"", name, "\": ",
    
                    Tcl_PosixError(interp), (char *) NULL);
    
            return TCL_ERROR;
    
          }
    
    
    --- 350,363 ----
    
              }
    
          }
    
    
    !     resultPtr = Tcl_NewObj();
    
    !     Tcl_IncrRefCount(resultPtr);
    
          charactersRead = Tcl_ReadChars(chan, resultPtr, toRead, 0);
    
          if (charactersRead < 0) {
    
            Tcl_ResetResult(interp);
    
            Tcl_AppendResult(interp, "error reading \"", name, "\": ",
    
                    Tcl_PosixError(interp), (char *) NULL);
    
    +       Tcl_DecrRefCount(resultPtr);
    
            return TCL_ERROR;
    
          }
    
    
    ***************
    
    *** 372,377 ****
    
    --- 374,381 ----
    
                Tcl_SetObjLength(resultPtr, length - 1);
    
            }
    
          }
    
    +     Tcl_SetObjResult(interp, resultPtr);
    
    +     Tcl_DecrRefCount(resultPtr);
    
          return TCL_OK;
    
      }
    
    
    PatchFiles:
    
    generic/tclIOCmd.c
    
    
    
    
    in 8.2.1 
    -- 11/18/1999 hobbs
    
  4. foundin changed to: "obsolete: 8.2"
  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: "62. (unused)"
  10. title changed to: "Tcl_ReadChars is unsafe for stacked channels"
  11. type changed to: "Bug"