Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: dc326a73b4b37d3acad86270fbab5b13dc0c3ea1ece12d3e6e5a0bb1f9c30d48
Ticket: 69b4f7eb379e7b806c0c144a36059ca55f569634
FilterInputBytes(): signed integer overflow, poor worst-case performance lengthening objPtr
User & Date: serhiy.storchaka on 2026-10-18 16:44:59
Changes

  1. foundin changed to: "8.6.18, 9.1.0"
  2. icomment:
    Still present in 9.1 (9.0 has the same code): <tt>Tcl_GetsObj()</tt>, <tt>TclGetsObjBinary()</tt> and <tt>FilterInputBytes()</tt> keep offsets and counts in <tt>int</tt>, so <nowiki>[gets]</nowiki> of a line over 2 GB panics in <tt>Tcl_SetObjLength</tt> ("length requested is negative"), returns a negative length with <tt>-translation binary</tt>, or crashes when a <tt>\r</tt> ends a buffer.
    
    Proposed fix in branch [/timeline?r=gets-long-lines|gets-long-lines]: <tt>Tcl_Size</tt> there, and the doubling of the buffer no longer overflows. Tests gets-bigdata-1 to 3 (constraint <tt>bigdata</tt>, about 6 GB of memory). The growth strategy when doubling fails is unchanged.
    
  3. login: "serhiy.storchaka"
  4. mimetype: "text/x-fossil-wiki"