Overview
| Artifact ID: | cceb47b58bb1e2c18bf96d5bd88d8ecd28c89791 |
|---|---|
| Ticket: | 218905ffffffffffffffffffffffffffffffffff
Tcl_ReadChars is unsafe for stacked channels |
| User & Date: | nobody on 2000-10-26 01:07:37 |
Changes
- assignee changed to: "nobody"
- cmimetype changed to: "text/plain"
- 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 - foundin changed to: "obsolete: 8.2"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- status changed to: "Open"
- submitter changed to: "nobody"
- subsystem changed to: "62. (unused)"
- title changed to: "Tcl_ReadChars is unsafe for stacked channels"
- type changed to: "Bug"