Skip to content
Tcl Source Code History Of Ticket 3033307
Login

History Of Ticket 3033307

Artifacts Associated With Ticket 3033307

  1. Ticket change [49ccd9487e] (rid 100104) by a_kovalenko on 2010-07-23 00:54:42:

    1. assignee initialized to: "dkf"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      binary decode base64 "[binary encode base64 u]" => u, as expected
      binary decode base64 "[binary encode base64 u] " => empty 
      
      Trailing space characters cause inner loop to run 4 times in "post-data-end" branch, increasing "cut" value each time, with 3 output bytes only. Thus the last byte of previous data is thrown away incorrectly.
      
      Patch attached.
      
      The code is still too liberal, accepting illegal base64. It would be better to borrow a correct, well-tested implementation from somewhere else.
      
    4. foundin initialized to: "obsolete: 8.6b1.1"
    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: "a_kovalenko"
    10. subsystem initialized to: "16. Commands A-H"
    11. title initialized to: "binary decode base64 breaks with trailing spaces"
    12. type initialized to: "Bug"
  2. Add attachment "tcl-base64-decode.patch" [45d304c32d] (rid 99411) by a_kovalenko on 2010-07-23 07:54:42.

  3. Ticket change [be27f12265] (rid 102028) by a_kovalenko on 2010-07-23 07:54:42:

    1. icomment:
      
      
      File Added - 380861: tcl-base64-decode.patch
      
      
      
    2. login: "a_kovalenko"
    3. mimetype: "text/plain"
    4. username: "a_kovalenko"
  4. Ticket change [ebd8fc4db3] (rid 103598) by dkf on 2010-07-23 16:03:32:

    1. assignee changed to: "patthoyts"
    2. icomment:
      Trailing spaces are *legal* in base64 anyway; the encoding specifies that whitespace is insignificant
      
      
    3. login: "dkf"
    4. mimetype: "text/plain"
    5. subsystem changed to: "12. ByteArray Object"
    6. username: "dkf"
  5. Ticket change [7104273b02] (rid 100595) by a_kovalenko on 2010-07-23 18:10:38:

    1. icomment:
      Clarification: I don't mean "whitespace" here when I say that it's too liberal. E.g. single-character string, "P", is illegal when it's the _whole_ base64 input, yet Tcl [binary decode] accepts it. "P===" is also illegal and also accepted. These "holes" may be fixed easily, too, but after that this function will look even more ugly. 
      
      It seems that ill-defined semantics of the `cut' variable (does it count bytes or 6bit units?) _is_ the cause of an impressive amount of "special-case" checks within such a small function.
      
      I believe that my patch at least provides correct decoding of _correct_ base64, so it may be useful as a palliative.
      
      
    2. login: "a_kovalenko"
    3. mimetype: "text/plain"
    4. username: "a_kovalenko"
  6. Ticket change [ef5cd41751] (rid 108976) by andygoth on 2012-10-18 09:03:57:

    1. icomment:
      I hit this problem in 8.6b3, and it had very serious consequences for my application, so I fixed it properly.
      
      I can't figure out how to attach a file here, so I put it on the Tcl Wiki: http://wiki.tcl.tk/tcl8.6b3-base64decode.patch .  Somebody please move that file here as a real attachment and delete that wiki page.
      
      This patch tidies up the semantics for the cut variable, and it does so by making the bsae64 decoder a bit more strict.  Only one or two ='s are allowed, and they must be at the end of the final block.  Therefore cut can only be nonzero at or after the final block, and it can only go up to two, since at most two bytes can be stripped from the output (there are only three output bytes per block).  But if there's whitespace following the final block, three is added to cut to strip the entire dummy block that the whitespace would otherwise generate.
      
      This patch adds some cases to binary.test to confirm that it's working as designed.  It also adds a lot of comments to the decode function to explain what it's doing.
      
      I'd make the code even stricter, specifically I'd require that the input be a multiple of four characters in length, but that breaks existing cases in the test suite.  Instead I added comments to document the current behavior regarding incomplete blocks.  With or without my patch applied, the behavior is:
      
      - If the input length (not counting whitespace) is 4n+1, where n is an integer, the last character is ignored.
      - If the input length is 4n+2, two ='s are assumed at end of input.
      - If the input length is 4n+3, one = is assumed at end of input.
      - If the input length is 4n, no massaging is necessary.
      
      Without my patch, trailing whitespace causes the final output character to be dropped.
      
      
      
    2. login: "andygoth"
    3. mimetype: "text/plain"
    4. username: "andygoth"
  7. Ticket change [39c4699d01] (rid 112447) by dkf on 2012-10-18 15:12:33:

    1. icomment:
      @andy: Only people with the right project permissions (i.e., people to whom we can assign the issue) can attach files to issues they didn't create.
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  8. Ticket change [367ec72d14] (rid 107112) by dgp on 2012-11-16 02:38:42:

    1. assignee changed to: "dkf"
    2. icomment:
      
      This sure sounds like something that ought to be fixed for 8.6.0,
      or have a real good understanding why not.
      
      
    3. login: "dgp"
    4. mimetype: "text/plain"
    5. priority changed to: "9 Immediate"
    6. username: "dgp"
  9. Ticket change [d2e66d594d] (rid 113605) by dgp on 2012-11-16 03:25:54:

    1. icomment:
      
      See branch bug-3033307 for the contributed patch from Andy Goth.
      Includes comments and tests.
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  10. Ticket change [928bae5e9f] (rid 120775) by dkf on 2012-11-20 18:56:42:

    1. icomment:
      The tests seem reasonable, given the existing definition of [binary decode base64].
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  11. Ticket change [0cfc1969f3] (rid 114280) by dkf on 2012-11-20 19:17:04:

    1. closedate changed to: "2012-11-20T12:17:04"
    2. closer changed to: "dkf"
    3. icomment:
      
      
      allow_comments - 1
      
      Confirmed that the tests detect the problem, and that it was a real problem that the patch fixed. Applied to trunk. Thanks!
      
      
    4. login: "dkf"
    5. mimetype: "text/plain"
    6. resolution changed to: "Fixed"
    7. status changed to: "Closed"
    8. username: "dkf"