Skip to content
Tcl Source Code History Of Ticket 2107634
Login

History Of Ticket 2107634

Artifacts Associated With Ticket 2107634

  1. Ticket change [3a88712452] (rid 112574) by brlcad on 2008-09-12 15:20:03:

    1. assignee initialized to: "msofer"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      We ran into a problem in BRL-CAD with the maximum command length in Tcl and have a fix that extends the maximum command limit approximately two times where it presently fails.  The provided patch pushes that limit up about 2x by checking for the overflow and clamping to maxint.  If that maxint limit is exceeded, then it now returns -1 instead of crashing too.
      
      The current behavior without the patch is that 'length' ends up overflowing causing a crash inside Tcl_SetObjLength() where it tries to use length (which is negative maxint) as an array index.
      
      For those wondering just how we'd actually blow out that limit, our (.asc) ASCII file format in BRL-CAD is essentially a Tcl transcript.  So to load a file, we just have Tcl parse the file.  Being a CAD package, our files are geometry.  One of the geometry types is a polygonal mesh... So when you have one mesh that is really big (which is really easy to do), you end up blowing out the command length.
      
      This fix should be credited to Bob Parker (BRL-CAD developer) if it is applied.  The patch was made against 8.5.1
      
      We fully admit that the patch isn't ideal, but it does resolve the problem from our standpoint without any negative consequences until the API can be improved.  As you're undoubtedly well-aware, DoReadChars() and friends need to not use int everywhere for string/buffer length tracking, instead using size_t's or something similarly longer (and fixed) instead of int.
      
      Cheers!
      Sean
      
      
      
    4. foundin initialized to: "None"
    5. is_private initialized to: "0"
    6. priority initialized to: "5 Medium"
    7. resolution initialized to: "None"
    8. status initialized to: "Open"
    9. submitter initialized to: "brlcad"
    10. subsystem initialized to: "45. Parsing and Eval"
    11. title initialized to: "extend maximum command length to maxint"
    12. type initialized to: "Patch"
  2. Add attachment "cmd_2x_bug.patch" [48a94434b8] (rid 99930) by brlcad on 2008-09-12 22:20:03.

  3. Ticket change [7350fa8aad] (rid 105028) by brlcad on 2008-09-12 22:20:03:

    1. icomment:
      
      
      File Added - 293150: cmd_2x_bug.patch
      
      
      
    2. login: "brlcad"
    3. mimetype: "text/plain"
    4. username: "brlcad"
  4. Ticket change [3a9ed7f7c4] (rid 112587) by dgp on 2008-09-15 11:47:38:

    1. assignee changed to: "andreas_kupries"
    2. subsystem changed to: "25. Channel System"
  5. Ticket change [1d5f7cdf14] (rid 90791) by dgp on 2009-02-03 23:22:17:

    1. icomment:
      
      Fixing another bug (2553906) we've recently
      added checks to Tcl_(Attempt)SetObjLength to
      reject negative length requests.  I'll try
      to find time to examine what impact that
      might have on this patch.
      
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  6. Ticket change [c49773cf43] (rid 111867) by dgp on 2009-02-03 23:22:18:

    1. assignee changed to: "dgp"
  7. Ticket change [260c0b6e50] (rid 88272) by brlcad on 2009-02-04 00:11:59:

    1. icomment:
      Thanks for the heads up.  We'll have to evaluate/merge the change if we update our bundled version of Tcl/Tk too, so it's good to know.  If/when we do before you examine the impact on your end, I'll update the patch.
      
      
    2. login: "brlcad"
    3. mimetype: "text/plain"
    4. username: "brlcad"
  8. Ticket change [470b95c33c] (rid 99619) by dgp on 2009-02-28 00:04:07:

    1. priority changed to: "9 Immediate"
  9. Ticket change [ec12e762bd] (rid 103644) by dgp on 2009-04-09 23:23:50:

    1. icomment:
      
      Your patch appears to be preventing the
      passing of a negative length value to
      Tcl_SetObjLength().  This means the new
      T_SOL behavior of panic on a negative
      length will be avoided by your patch.  The
      next releases should not harm your
      patch's effectiveness.
      
      Leaving this open, since the failure of
      the caller(s) of T_SOL to take notice
      of and react to string length overflow
      remains a problem, and the development
      of a better patch to go into the core
      sources still needs doing.  
      
      
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. priority changed to: "7 High"
    5. username: "dgp"
  10. Ticket change [a1a3d0db96] (rid 109761) by dgp on 2009-10-02 03:33:03:

    1. priority changed to: "9 Immediate"
  11. Ticket change [9d622c0d2e] (rid 96296) by dgp on 2009-10-07 03:03:37:

    1. icomment:
      
      Related issue Bug 2418583 indicates
      that overflows with Tcl_ExternalToUtf() 
      also need attention.
      
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  12. Ticket change [4d41ad4126] (rid 127024) by dgp on 2009-10-15 02:42:47:

    1. icomment:
      
      In the submitted patch, when a read tries to
      go beyond the capacity of a Tcl_Value,
      ReadChars() returns -1.  What does that do?
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  13. Ticket change [74c4ff3b56] (rid 105265) by dgp on 2009-10-15 02:55:06:

    1. icomment:
      
      
      File Added - 346653: 2107634.patch
      
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  14. Add attachment "2107634.patch" [4bab356d1f] (rid 126753) by dgp on 2009-10-15 02:55:06.

  15. Ticket change [b3ce450199] (rid 124915) by dgp on 2009-10-15 02:58:41:

    1. icomment:
      
      Attached a patch that better governs buffer growth so that
      ReadChars can keep reading chars up until the read that
      will overflow the limits of Tcl values.  On that read attempt,
      there will be a panic.
      
      Please give the patch a try and see if it solves the BRL-CAD
      problems at least as well as the contributed patch.
      
      If there is some value in having ReadChars() return -1 rather
      than panic when the actual limits are reached, please explain
      in a followup comment.
      
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  16. Add attachment "2107634-2.patch" [672be2c1e1] (rid 102855) by dgp on 2009-10-15 20:28:58.

  17. Ticket change [83578bee3d] (rid 117365) by dgp on 2009-10-15 20:28:58:

    1. icomment:
      
      
      File Added - 346764: 2107634-2.patch
      
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  18. Ticket change [8ee2e526bf] (rid 120194) by dgp on 2009-10-15 20:29:26:

    1. icomment:
      
      Second version of the patch adds similar fixes
      to FilterInputBytes().
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  19. Ticket change [eec3a09070] (rid 108871) by dgp on 2009-10-16 01:07:51:

    1. assignee changed to: "andreas_kupries"
  20. Ticket change [532cc38f9d] (rid 126436) by andreas_kupries on 2009-10-20 03:54:56:

    1. icomment:
      dgp, the patch looks ok to me in general. Even if I do not fully understand the exact tweaks re dstNeeded and/or spaceLeft, with the TCL_UTF_MAX moving between them.
      
      
    2. login: "andreas_kupries"
    3. mimetype: "text/plain"
    4. username: "andreas_kupries"
  21. Ticket change [4a6d94521d] (rid 126535) by andreas_kupries on 2009-10-20 03:55:05:

    1. assignee changed to: "dgp"
  22. Ticket change [51961aa16e] (rid 126158) by dgp on 2009-10-20 04:46:56:

    1. icomment:
      
      The problem to avoid is when the "length" value
      passed to Tcl_(Attempt)SetObjLength no longer
      really represents what the caller desires because
      of integer overflow.  The really trouble some case
      is when offset is already INT_MAX.  Then the
      doubling rule led to an attempt to allocate a new
      string of length 2*offset + TCL_UTF_MAX + 1,
      which wraps around the unsigned integer range
      and allocates a string of length 2.  Then later
      code tries to write long strings into a buffer of length
      2 and segfaults.
      
      Shifting the location of the TCL_UTF_MAX offset
      in the calculation means that the calculation of
      length is limited to 2*offset, which can be no bigger
      that UINT_MAX -1, which when interpreted as a signed
      int is negative, and triggers the appropriate failure.
      
      The whole TCL_UTF_MAX shifting business is needed
      to satisfy the demands of the Tcl_ExternalToUtf() routine.
      
      The +1 that used to be there was apparently in place to
      make sure that space for a terminating NUL was allocated.
      Since the Tcl_*SetObjLength() routines already provide
      for this, it was removed.
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  23. Ticket change [49c63c7c4e] (rid 100100) by dgp on 2009-10-20 04:47:11:

    1. assignee changed to: "andreas_kupries"
  24. Ticket change [9679f2cf6f] (rid 106335) by dgp on 2009-10-20 05:00:48:

    1. icomment:
      
      accepted for 8.5.8 and 8.6b2.
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  25. Ticket change [2cbcb3a129] (rid 118954) by dgp on 2009-10-20 05:00:51:

    1. assignee changed to: "dgp"
    2. closedate changed to: "2009-10-19T22:00:51"
    3. closer changed to: "dgp"
    4. icomment:
      
      
      allow_comments - 1
      
      
      
    5. login: "dgp"
    6. mimetype: "text/plain"
    7. resolution changed to: "Accepted"
    8. status changed to: "Closed"
    9. username: "dgp"
  26. Ticket change [7a6dbbf5ce] (rid 90317) by andreas_kupries on 2009-10-20 05:11:09:

    1. icomment:
      Thanks for the explanation. It makes sense.
      
      
    2. login: "andreas_kupries"
    3. mimetype: "text/plain"
    4. username: "andreas_kupries"