Tk Library Source Code

View Ticket
Login
Ticket UUID: 3477684
Title: CRC of binary string: bad parsing
Type: Bug Version: None
Submitter: tmmenezes Created on: 2012-01-23 11:35:18
Subsystem: crc Assigned To: patthoyts
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2012-01-24 03:28:24
Resolution: Fixed Closed By: patthoyts
    Closed on: 2012-01-23 20:28:24
Description:
Calculating the CRC of a binary string can break the library.
This happens when the input binary string includes the ASCII code for text symbol '-'.
The proc parsing the input data breaks the input binary string into options because of '-'
See attached file with example.
User Comments: patthoyts added on 2012-01-24 03:28:24:

allow_comments - 1

Typically tcl commands use "--" to indicate the end of option processing. If you always add this before the data parameter then you can avoid this problem in many commands that accept options (for instance, switch is best used as 'switch -exact -- $option { .... }').
However, it is also quite simple to handle a final data parameter that happens to have a leading hyphen. This was fixed previously for crc32 and other tcllib functions. I've applied the same fix here. In the meantime - use '--'.

tmmenezes added on 2012-01-23 19:28:12:
The bug is located at:

proc ::crc::crc-ccitt {args} {
    return [eval [list crc -impl [namespace origin CRC-CCITT] -seed 0xFFFF]\
                $args]
}

and can be fixed by appending '--' at the end of all the options, and before $args:

proc ::crc::crc-ccitt {args} {
    return [eval [list crc -impl [namespace origin CRC-CCITT] -seed 0xFFFF --]\
                $args]
}

tmmenezes added on 2012-01-23 18:35:19:

File Added - 433794: crc_bug.tcl

Attachments: