Tk Library Source Code

View Ticket
Login
Ticket UUID: 2976290
Title: decode fails
Type: Bug Version: None
Submitter: daapp Created on: 2010-03-25 04:45:39
Subsystem: base64 Assigned To: andreas_kupries
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2010-07-07 02:16:46
Resolution: Fixed Closed By: andreas_kupries
    Closed on: 2010-07-06 19:16:46
Description:
This code:

::base64::decode s=GQMRAk5WXhsABh0NEx4RXBocBVgBHQMXHRgEFltMQENQXEFOExJVQ0RAQERUQ0dAEhYEExVIRRVVFENWKxMKABsPGBI6LRoYLhsEFhsXGFkXEwZXGQMIHg==

produce an error:
can't use empty string as operand of "&"
    while executing
"expr {($v << 2) | (($w & 0x30) >> 4)}"
    (procedure "::base64::decode" line 27)
    invoked from within
"::base64::decode s=GQMRAk5WXhsABh0NEx4RXBocBVgBHQMXHRgEFltMQENQXEFOExJVQ0RAQERUQ0dAEhYEExVIRRVVFENWKxMKABsPGBI6LRoYLhsEFhsXGFkXEwZXGQMIHg=="
    ("uplevel" body line 1)
    invoked from within
"uplevel #0 {::base64::decode s=GQMRAk5WXhsABh0NEx4RXBocBVgBHQMXHRgEFltMQENQXEFOExJVQ0RAQERUQ0dAEhYEExVIRRVVFENWKxMKABsPGBI6LRoYLhsEFhsXGFkXEwZXGQMIHg=..."

The source string may be invalid, but the code should not fail like this.
User Comments: andreas_kupries added on 2010-07-07 02:16:46:

allow_comments - 1

Changed code to detect the situation and throw a more properly looking error ('Not enough data to process padding'). This is now version 2.4.2 of base64.