Artifacts Associated With Ticket 2738427fffffffff
Ticket change [390f21f693] (rid 112321) by dgp on 2009-04-06 19:41:37:
- assignee initialized to: "nijtmans"
- cmimetype initialized to: "text/plain"
- comment initialized to:
Tcl_NumUtfChars(unicode, -1) can return negative counts if there are really more than INT_MAX Utf chars located at unicode before a terminating \0 is seen.
- foundin initialized to: "None"
- is_private initialized to: "0"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "dgp"
- subsystem initialized to: "44. UTF-8 Strings"
- title initialized to: "Tcl_NumUtfChars(..., -1) no overflow check"
- type initialized to: "Bug"
Ticket change [ce3a494437] (rid 96017) by dgp on 2009-04-11 03:09:53:
- icomment:
comment test....
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [c494b2dd0c] (rid 136998) by jan.nijtmans on 2014-02-21 19:07:44:
- assignee changed to: "jan.nijtmans"
Ticket change [9aec2b5f75] (rid 154379) by jan.nijtmans on 2017-06-08 12:26:18:
- closer changed to: "nobody"
- comment changed to:
Tcl_NumUtfChars(unicode, -1) can return negative counts if there are really more than INT_MAX Utf chars located at unicode before a terminating \0 is seen. In addition, there is another overflow problem, e.g. Tcl_NumUtfChars("\xE2\x82\xAC", 2): This call returns 1 instead of the expected 2. - icomment:
Problem with the Tcl_NumUtfChars("\xE2\x82\xAC", 2) call is that the 3th byte is read, even though a length of only 2 bytes was requested. Since with only 2 bytes, the unicode character is incomplete, Tcl_NumUtfChars() should count this as 2 separate bytes. - login: "jan.nijtmans"
- mimetype: "text/plain"
- severity changed to: "Minor"
- title changed to: "Tcl_NumUtfChars(...) no overflow check"
Ticket change [e889948306] (rid 154387) by jan.nijtmans on 2017-06-08 12:41:17:
- closedate changed to: "2457913.02867168"
- closer changed to: "jan.nijtmans"
- icomment:
Fixed in core-8-5-branch, core-8-6-branch and trunk. For Tcl 9 it would be better to change the signature of Tcl_NumUtfChars (using size_t length parameter and return value in stead of int), but that's out-of-scope for this ticket.
- login: "jan.nijtmans"
- mimetype: "text/x-fossil-wiki"
- resolution changed to: "Fixed"
- status changed to: "Closed"
Ticket change [4308e5f95b] (rid 154389) by dgp on 2017-06-08 12:54:47:
- closedate changed to: "2457913.03804544"
- closer changed to: "dgp"
- icomment:
Thanks for finding and addressing this old ticket. I'm worried it's not quite a correct answer. The overflow detection is only done after the loop ends, and not at each pass through the loop. This leaves open the possibility that i could circle all the way back to a non-negative value before '\0' is seen and we get a count that's (UINT_MAX + 1) too small. Since the return type can only handle a value up to INT_MAX, and since there's no error reporting channel available, should this routine just panic for inputs outside that supportable range?
- login: "dgp"
- mimetype: "text/plain"
Ticket change [743cd7c154] (rid 154394) by jan.nijtmans on 2017-06-08 13:45:29:
- closedate changed to: "2457913.07326046"
- closer changed to: "jan.nijtmans"
- icomment:
Yes I'm aware that this is not 100% correct yet, in Tcl 9 we can do better. Panicing would be OK to me, it's not a use-case that will be encountered in real life ..... Thank you, Don, for your feedback!
- login: "jan.nijtmans"
- mimetype: "text/x-fossil-wiki"
Ticket change [57658785df] (rid 154395) by dgp on 2017-06-08 14:22:55:
- assignee changed to: "dgp"
- closer changed to: "nobody"
- icomment:
Adding another way for a Tcl-using program to crash doesn't strike me as a great answer either. I need more thought on it. Re-opening and assigning to myself as a reminder to look again sometime. Not changing anything checked in though. It's at least as good as what was there before.
- login: "dgp"
- mimetype: "text/plain"
- status changed to: "Open"
Ticket change [d07e088e19] (rid 154396) by jan.nijtmans on 2017-06-08 14:54:25:
- icomment:
Sure, Don, please go ahead! I'm out of ideas for 8.x ....
- login: "jan.nijtmans"
- mimetype: "text/plain"
- icomment:
Ticket change [ba5bbee20a] (rid 181854) by dgp on 2020-04-16 19:53:06:
- closedate changed to: "2458956.32854185"
- closer changed to: "dgp"
- icomment:
Fix completed in 8.5 now.
- login: "dgp"
- mimetype: "text/plain"
- status changed to: "Closed"