Tk Library Source Code

View Ticket
Login
Ticket UUID: 524712
Title: md5::md5 fails with Trf2.1p2 (tcllib1.2)
Type: Bug Version: None
Submitter: goosen Created on: 2002-03-02 06:59:58
Subsystem: md5 Assigned To: andreas_kupries
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2002-03-03 05:48:25
Resolution: Invalid Closed By: andreas_kupries
    Closed on: 2002-03-02 22:48:25
Description:
In tclsh (8.3):

% package require tcllib
1.2
% md5::md5 507
::hex: wrong # args, all options require an argument

I have Trf 2.1p2 installed, which means the following
code is executed from md5.tcl:
-------------------------------------------
# Trf is available, so implement the functionality
provided here
    # in terms of calls to Trf for speed.

    proc ::md5::md5 {msg} {
string tolower [::hex -mode encode [::md5 $msg]]
    }
-------------------------------------------

The reason for the failure is that [::md5 $msg] returns
a binary result starting with '-', which causes the
::hex to think there is another option.
 
The fix is to insert "--" following the "encode":

-------------------------------------------
    proc ::md5::md5 {msg} {
string tolower [::hex -mode encode -- [::md5 $msg]]
    }
-------------------------------------------

There is at least one other occurrence of the same bug
in md5.tcl, and I would imagine this could also occur
where ::hex or other encoding functions are called.

I'm willing to fix this bug.
User Comments: andreas_kupries added on 2002-03-03 05:48:25:
Logged In: YES 
user_id=75003

This bug is already fixed in the CVS head of tcllib/md5.
Excerpt of ChangeLog:

2002-02-07  Andreas Kupries  

* md5.tcl: Adding -- to hex/md5 commands to prevent
  misinterpretation of data if starting with -.