Skip to content
Tcl Source Code History Of Ticket 6015221f59
Login

History Of Ticket 6015221f59

Artifacts Associated With Ticket 6015221f59

  1. Ticket change [90eaad9614] (rid 153462) by anonymous on 2017-05-03 02:55:38:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/plain"
    4. comment initialized to:
      if "binary scan" is requesting too much character data, it just segfaults instead of complaining that too much data is requested.
      
      % binary scan x a172983798173981a r n
      Segmentation fault (core dumped)
      
    5. is_private initialized to: "0"
    6. login: "anonymous"
    7. priority initialized to: "5 Medium"
    8. private_contact initialized to: "ab5c04693d4ea3b3339a1e41947ceb8da8054625"
    9. resolution initialized to: "None"
    10. severity initialized to: "Minor"
    11. status initialized to: "Open"
    12. submitter initialized to: "anonymous"
    13. subsystem initialized to: "16. Commands A-H"
    14. title initialized to: "binary scan segfaults when too much a is requested"
    15. type initialized to: "Bug"
  2. Ticket change [ac56560238] (rid 153463) by aspect on 2017-05-03 06:21:31:

    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"
  3. Ticket change [136ef3e43e] (rid 153464) by jan.nijtmans on 2017-05-03 07:50:58:

    1. icomment:
      Actually, Segmentation faults from pure Tcl code is always bad ....
      
      It would be nice if this could be fixed in at least Tcl 8.6.7. Suggestion for a fix always welcome?
      
    2. login: "jan.nijtmans"
    3. mimetype: "text/plain"
    4. severity changed to: "Severe"
  4. Ticket change [0a294c5250] (rid 153466) by sebres on 2017-05-03 09:29:25:

    1. assignee changed to: "sebres"
    2. foundin changed to: ">= 8.5 (*nix only)"
    3. icomment:
      I guess something like this in GetFormatSpec would be more appreciated:
      ```
      if (*countPtr) < 0 {
        countPtr = BINARY_ALL;
      }
      ```
      According to documentation "count is a non-negative decimal integer", so I think in this case BINARY_ALL is a little bit better as boom.
      
      If no objections I would fix it this way in all 3 major branches (including test cases).
      
      BTW. Strange is, that at all not reproduceable under windows (neither x86 nor x64), but pretty segfaulting on linux in all versions.
      
    4. login: "sebres"
    5. mimetype: "text/plain"
    6. priority changed to: "7 High"
    7. severity changed to: "Critical"
  5. Ticket change [8132ecf041] (rid 153468) by sebres on 2017-05-03 09:49:27:

    1. icomment:
      Another way would be to redefine GetFormatSpec (and count as unsigned), like:
      
        GetFormatSpec( .. unsigned int *countPtr .. )
        unsigned int count;
      
      and 
      
        #define BINARY_ALL ((unsigned int)-1)
        ...
      
      So "overflow" will reach both special cases only by following ranges (accoring INT_MAX):
      
        binary scan x a[format %ld 0xffffffff]a r n; # equal BINARY_ALL
        binary scan x a[format %ld 0xfffffffe]a r n; # equal BINARY_UNSIGNED
      
    2. login: "sebres"
    3. mimetype: "text/plain"
  6. Ticket change [8a305859d0] (rid 153572) by dgp on 2017-05-04 16:00:31:

    1. icomment:
      
      Seems to me the root of the issue is making a
      call to strtoul() without checking for the
      various errors that can result from it.
      
      This has been wrong since the dawn of Tcl's
      CVS history.
      
      There are a handful of other strtoul() calls
      here and there in Tcl. An audit of all of them
      would be a good idea.
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  7. Ticket change [dfb562cf4d] (rid 153590) by dgp on 2017-05-05 19:18:30:

    1. assignee changed to: "dgp"
    2. closedate changed to: "2457879.30452203"
    3. closer changed to: "dgp"
    4. icomment:
      
      fixed on all dev branches
      
    5. login: "dgp"
    6. mimetype: "text/plain"
    7. resolution changed to: "Fixed"
    8. status changed to: "Closed"
    9. subsystem changed to: "12. ByteArray Object"