Skip to content
Tcl Source Code History Of Ticket eb816947b3
Login

History Of Ticket eb816947b3

Artifacts Associated With Ticket eb816947b3

  1. Ticket change [889750c89c] (rid 175114) by crn on 2019-09-12 09:38:22:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/plain"
    4. comment initialized to:
      There is a problem in Tcl_SplitObjCmd when splitting a binary string with only one caracter, code relies on strchr which attends a nul caracter in end of string. But, in some special cases, this caracter isn't present and Tcl crashes. String size is known, so we need to use it by replacing strchr by memchr.
      
    5. foundin initialized to: "3.6.9"
    6. is_private initialized to: "0"
    7. login: "crn"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "2dbdba94c91624eb66b9964b9b1759d6c2dd4faa"
    10. resolution initialized to: "None"
    11. severity initialized to: "Important"
    12. status initialized to: "Open"
    13. submitter initialized to: "crn"
    14. subsystem initialized to: "12. ByteArray Object"
    15. title initialized to: "Issue with binary string and split command"
    16. type initialized to: "Patch"
  2. Add attachment "tcl_split_obj_cmd.patch" [07d43d3ad0] (rid 175115) by crn on 2019-09-12 09:39:19.

  3. Ticket change [56d5069eff] (rid 175116) by crn on 2019-09-12 09:48:19:

    1. foundin changed to: "8.6.9"
    2. login: "crn"
    3. mimetype: "text/plain"
  4. Add attachment "tcl_split_obj_cmd_v2.patch" [162a1b52b7] (rid 175117) by crn on 2019-09-12 10:05:33.

  5. Ticket change [f1dfabb4b2] (rid 175188) by dgp on 2019-09-13 12:33:07:

    1. icomment:
      
      Can you provide a demonstration script?
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  6. Ticket change [dc244857c8] (rid 175189) by crn on 2019-09-13 13:03:44:

    1. icomment:
      Sorry, I am not able to reproduce it with a simple script. It happens in a complex program, the string we wanted to split comes from a read command while the file is written (not sure if this matter). While looking at C code through a debugger, we saw that Tcl_StringObj length was ok, "bytes" pointer was pointing on a previous string (longer than the current, we clearly older values after the current string) but no '\0' at end of current string.
      So the scenario implies a buffer reusage and reading a file with variable chunk size.
      
    2. login: "crn"
    3. mimetype: "text/plain"
  7. Ticket change [82b1ea2fa9] (rid 175195) by dgp on 2019-09-13 13:29:49:

    1. icomment:
      
      In that scenario, the right thing to do is to fix the bug, not to make the [split] command more tolerant of malformed inputs.
      
      In any valid Tcl_Obj struct where objPtr->bytes is not NULL, it must be that
      
          (objPtr->bytes[objPtr->length] == '\0')
      
      at any time when control over that struct changes hands, as in passing as
      an argument. Whatever code has failed to maintain that invariant is where
      the bug is.
      
      Any further tips you can offer on finding that bug are welcome. When you encounter it, are any extensions in use?
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  8. Ticket change [46c68f96f5] (rid 175196) by crn on 2019-09-13 13:52:02:

    1. icomment:
      In Tcl_SetObjLength :
      objPtr->bytes[length] = 0;
      But in Tcl_SetByteArrayObj (no '\0') :
      byteArrayPtr = ckalloc(BYTEARRAY_SIZE(length));
      memcpy(byteArrayPtr->bytes, bytes, (size_t) length);
      
      I don't see where Tcl_NewByteArray adds '\0'.
      
      My program uses Tk and TableList.
      
    2. login: "crn"
    3. mimetype: "text/plain"
  9. Ticket change [062c2268c8] (rid 175197) by dgp on 2019-09-13 14:04:38:

    1. assignee changed to: "dgp"
    2. icomment:
      
      Thanks! Will take a look.
      
    3. login: "dgp"
    4. mimetype: "text/plain"
  10. Ticket change [202db058f2] (rid 175198) by dgp on 2019-09-13 14:09:20:

    1. icomment:
      
      Tcl_SetByteArrayObj(objPtr, bytes, length) sets objPtr->bytes to NULL.
      
      It also fills another array objPtr->internalRep.twoPtrValue.ptr1->bytes[] and
      does not terminate that data with '\0' (by design of that internal rep), but
      that has nothing to do with what [split] examines.
      
    2. login: "dgp"
    3. mimetype: "text/plain"