Tcl Source Code

View Ticket
Login
Ticket UUID: 1283976
Title: Tcl_UniCharToUtf mishandles negative input
Type: Bug Version: obsolete: 8.4.11
Submitter: dgp Created on: 2005-09-07 13:55:34
Subsystem: 44. UTF-8 Strings Assigned To: dgp
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2005-09-07 22:31:43
Resolution: Fixed Closed By: dgp
    Closed on: 2005-09-07 15:31:43
Description:
dkf% scan [format %c -1] %c%c%c
255 191 {}
...
[09:43]dkf% string bytelength [format %c -1]
2
...
[09:43]dkfSo, [format %c -1] is *wrong*
...
[09:44]dgphmmm... Tcl_UniCharToUtf accepts an "int"
argument instead of a "Tcl_UniChar" one. 
[09:44]dkfI think that's because some compilers
aren't keen on arguments narrower than a word 
[09:45]dgpbut the logic of the routine assumes an
unsigned input.
rmaxdgp: IIRC I also wondered about this when I worked
on the -nocase stuff some time ago, and Jeff knew the
reason why it is so.
[09:45]dkfI think T_UCTU should cast it's argument to
Tcl_UniChar
[09:46]dkf(at the very least)
...
[09:49]dgpok, so the flaw is in T_UCTU and not
[format] itself ten
[09:53]dkf[format] shouldn't be able to step outside
the internal encoding model
User Comments: dgp added on 2005-09-07 22:31:43:
Logged In: YES 
user_id=80530

patches committed.

dgp added on 2005-09-07 21:32:21:

File Added - 148329: 1283976-85.patch

dgp added on 2005-09-07 21:32:13:
Logged In: YES 
user_id=80530


corresponding patch for the HEAD

dgp added on 2005-09-07 21:22:33:

File Added - 148328: 1283976.patch

dgp added on 2005-09-07 21:22:25:
Logged In: YES 
user_id=80530


attached patch is fix and test

Attachments: