Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: ac56560238e010c042297768da61877fa2897a9b
Ticket: 6015221f59fd742aac833c7a4521de9745c8c868
binary scan segfaults when too much a is requested
User & Date: aspect on 2017-05-03 06:21:31
Changes

  1. icomment:
    playing around in gdb on core-8-5-branch, the problem in this case seems to be that after GetFormatSpec(&format, &cmd, &count, &flags), count is added to offset making it point outside the buffer.
    
    Specifically, this is wrong:
    
    GetFormatSpec( .. int *countPtr .. ) {
       (*countPtr) = strtoul( .. )
    }
    
    Similar issue likely exists in [binary format].
    
    Simplest fix is probably to return 0 if the strtoul() result is <0.  Else Tcl_BinaryObjCmd() needs to check after each call whether count is BINARY_UNSIGNED, BINARY_ALL, >=0 and otherwise TCL_ERROR.
    
    Note:  this looks like a relatively easily exploitable memory corruption bug, for anywhere untrusted users can provide format arguments to [binary].
    
  2. login: "aspect"
  3. mimetype: "text/plain"