Bug 166245

Summary: Incorrect MD5 checksums from md5sum
Product: [Fedora] Fedora Reporter: Tim <ack210t>
Component: coreutilsAssignee: Tim Waugh <twaugh>
Status: CLOSED NOTABUG QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 3   
Target Milestone: ---   
Target Release: ---   
Hardware: i686   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2005-08-18 09:46:02 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Tim 2005-08-18 09:12:26 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.10) Gecko/20050720 Fedora/1.0.6-1.1.fc3 Firefox/1.0.6

Description of problem:
The md5sum utility generates incorrect MD5 checksums. For instance:

$ echo "abc" | md5sum
0bee89b07a248e27c83fc3d5951213c1  -

This value is inconsistent with both the RFC 1321 test suite (RFC 1321 pg. 21) and the output produced by the OpenSSL library, both of which generate a digest value of:

900150983cd24fb0d6963f7d28e17f72

Downloading the tarball from GNU and exploring the source, the computation is done in lib/md5.c. In the current version (5.2.1), the output of md5_buffer() function is correct (matching the RFC), while the output of md5_stream(), the function called by the md5sum utility, is not.

I thought I would post this here while I try to find the problem in the source. It seems surprising that this hasn't been reported.

Tim

Version-Release number of selected component (if applicable):
coreutils-5.2.1-31

How reproducible:
Always

Steps to Reproduce:
1. As described above
2.
3.
  

Additional info:

Comment 1 Karsten Hopp 2005-08-18 09:46:02 UTC
echo appends a newline unless you use the -n parameter, this changes the   
md5sum.   
Try    
   echo -n  "abc" | md5sum  
 

Comment 2 Tim 2005-08-18 10:07:30 UTC
Yep! I also found that vim apparently appends a newlines at the end of the file,
even when no explicit RETURN is entered, so that explains the original
file-based problem as well. Sorry about that!

Tim