Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2015-11-11
14:14 • Closed ticket [5da26d4760]: Tcl_LoadFile() segfaults if "interp" is NU... artifact: 838a6fb9b6 user: jan.nijtmans
2015-10-07
13:16 • Pending ticket [5da26d4760]. artifact: 4be37560ba user: jan.nijtmans
13:14
Where "interp" is only used for error-reporting, it can be allowed to be NULL. This should fix [5da2... check-in: 5034c136a8 user: jan.nijtmans tags: trunk
2015-10-05
16:37 • New ticket [5da26d4760] Tcl_LoadFile() segfaults if "interp" is NULL</... artifact: 6e74898724 user: rkeene

Tcl_LoadFile() segfaults if "interp" is NULL

Closed / Fixed5da26d47606ec035175a8579852d181b0a53eaa7Created 11 years agoUpdated 11 years ago
Descriptionwiki2015-10-05 16:37:39
Calling Tcl_LoadFile() with interp as NULL results in Tcl_ResetResult(NULL) being called. Tcl_ResetResult(NULL) segfaults rather early on after attempting to dereference NULL as if it were a pointer to a (Tcl_Interp).

GDB output:


    Program received signal SIGSEGV, Segmentation fault.
    0x00007ffff7b43a29 in ResetObjResult.isra.0 () from /opt/appfs/core.appfs.rkeene.org/tcl/linux-x86_64/8.6.3/lib/libtcl8.6.so
    (gdb) bt
    #0  0x00007ffff7b43a29 in ResetObjResult.isra.0 () from /opt/appfs/core.appfs.rkeene.org/tcl/linux-x86_64/8.6.3/lib/libtcl8.6.so
    #1  0x00007ffff7b444f0 in Tcl_ResetResult () from /opt/appfs/core.appfs.rkeene.org/tcl/linux-x86_64/8.6.3/lib/libtcl8.6.so
    #2  0x00007ffff7b2622b in Tcl_LoadFile () from /opt/appfs/core.appfs.rkeene.org/tcl/linux-x86_64/8.6.3/lib/libtcl8.6.so
    #3  0x00007ffff4c00d5c in tclpkcs11_int_load_module () from /opt/appfs/rkeene.org/tclpkcs11/platform/latest/lib/tclpkcs110.9.10/tclpkcs11.so

Code:


MODULE_SCOPE void *tclpkcs11_int_load_module(const char *pathname) {
        int tcl_rv;
        Tcl_Obj *pathnameObj;
        Tcl_LoadHandle *new_handle;
        new_handle = (Tcl_LoadHandle *) ckalloc(sizeof(*new_handle));
        pathnameObj = Tcl_NewStringObj(pathname, -1);
        Tcl_IncrRefCount(pathnameObj);
        tcl_rv = Tcl_LoadFile(NULL, pathnameObj, NULL, 0, NULL, new_handle);
        Tcl_DecrRefCount(pathnameObj);
...
Referenced by1
  • 5034c136a8Where "interp" is only used for error-reporting, it can be allowed to be NULL. This should fix [5da26d4760]: Tcl_LoadFile() segfaults if "interp" is NULL. check-in2015-10-07 13:14:27
jan.nijtmanswiki2015-10-07 13:16:44

Should be fixed by [5034c136a8039265]. Please confirm.

Thanks for the report.

jan.nijtmans Closed ticket [5da26d4760]. [History diff]2015-11-11 14:14:02
Log in (anonymous is fine) to add a comment.