Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 108653 - dcfldd calculates wrong MD5 sums when compiled as 64Bit app under AMD64
Summary: dcfldd calculates wrong MD5 sums when compiled as 64Bit app under AMD64
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: High major
Assignee: AMD64 Testing Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-10-09 13:25 UTC by Martin Scharrer
Modified: 2005-10-31 12:20 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Fix for wrong MD5 sums with 64bit binaries for AMD64 (dcfldd-1.2.4_md5_amd64_fix.patch,1.01 KB, patch)
2005-10-11 14:48 UTC, Martin Scharrer
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Scharrer 2005-10-09 13:25:50 UTC
The application sys-apps/dcfldd (which is an enhanced version of dd) produces 
wrong MD5 sums when compiled as    
a 64Bit app under AMD64. The sums are different from the sums generated by  
'md5sum'.  
It works fine when compiled as a 32Bit app under AMD64.  
SHA1 sums are correct with both 64 and 32bit.   

Reproducible: Always
Steps to Reproduce:
1. compile dcfldd (1.2.2 or 1.2.4) under AMD64 as a 64Bit ELF binary  
2. run something like:   
$ dcfldd if=/dev/zero bs=10k hash=md5 count=30 hashwindow=100k | md5sum -  
3. check the sum given in the "Total (md5):" line with the output of md5sum,  
both should be equal, but aren't  
4. You can check the intermedian MD5 sums with: 
$ dd if=/dev/zero bs=100k count=1 | md5sum - 
 
Note: It works if you using SHA1 sums instead:  
$ dcfldd if=/dev/zero bs=10k hash=sha1 count=30 hashwindow=100k | sha1sum -  
or compile dcfldd with CFLAGS="-m32" to a 32bit ELF binary.   
   
Actual Results:  
With this:  
$ dcfldd --version  
dcfldd (dcfldd) 1.2.4  
$ file `which dcfldd`  
/usr/bin/dcfldd: ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for  
GNU/Linux 2.4.1, dynamically linked (uses shared libs), stripped  
  
I get:  
dcfldd if=/dev/zero bs=10k hash=md5 count=30 hashwindow=100k  | md5sum -  
0 - 102400: 5dc6ed28dcde75b5b6983d2c66717fea  
102400 - 204800: 5dc6ed28dcde75b5b6983d2c66717fea  
204800 - 307200: 5dc6ed28dcde75b5b6983d2c66717fea  
Total (md5): 858120c6ffe109f66f8627bb8910f824  
  
30+0 records in  
30+0 records out  
90aeded9922cf8946ea7858635493724  -  
$ dd if=/dev/zero bs=100k count=1 | md5sum - # check intermedian MD5 sums 
4c6426ac7ef186464ecbb0d81cbfcb1e  - 
 

Expected Results:  
  
$ dcfldd if=/dev/zero bs=10k hash=md5 count=30 hashwindow=100k | md5sum -   
0 - 102400: 4c6426ac7ef186464ecbb0d81cbfcb1e   
102400 - 204800: 4c6426ac7ef186464ecbb0d81cbfcb1e   
204800 - 307200: 4c6426ac7ef186464ecbb0d81cbfcb1e   
Total (md5): 90aeded9922cf8946ea7858635493724   
   
30+0 records in   
30+0 records out   
90aeded9922cf8946ea7858635493724  -   
   
$ dd if=/dev/zero bs=100k count=1 | md5sum -   
4c6426ac7ef186464ecbb0d81cbfcb1e  -   
   
I get the above when I compile it with CFLAGS="-m32 -O2 -pipe". 
 
$ file `which dcfldd` 
/usr/bin/dcfldd: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for 
GNU/Linux 2.4.1, dynamically linked (uses shared libs), stripped 
 
 

I checked version 1.2.2 and 1.2.4 both are calculating the same wrong MD5 sums    
Both are calculating right SHA1 sums. Other SHA sums are untested because of    
the lack of other calculation tools.   
   
The sums are wrong, but always identical by identical input.    
    
I think the output of 'md5sum' is right and so a valid reference. So for I    
know the Makefile of 'md5sum' runs some basic tests after compilation.
Comment 1 Martin Scharrer 2005-10-09 13:47:07 UTC
I was also sending a but report to the author  
Nicholas Harbour <nicholasharbour@yahoo.com> 
Comment 2 Martin Scharrer 2005-10-11 14:48:38 UTC
Created attachment 70418 [details, diff]
Fix for wrong MD5 sums with 64bit binaries for AMD64
Comment 3 Martin Scharrer 2005-10-11 14:49:13 UTC
I checked the source code today and I was able to locate the   
problem very fast:   
the MD5 code (md5.c, md5.h) is using a constant typedef for UINT4 for a 32bit   
unsigned integer type.   
The correct working SHA1 has the correct including of <stdint.h> and usage of   
uint32_t as 32bit unsigned integer type.   
I made a small patch by adding the include of <stdint.h> and typedef'ing of   
UINT4 to uint32_t.   
   
It's now working correctly at my system.   
 
Comment 4 Simon Stelling (RETIRED) gentoo-dev 2005-10-12 01:15:42 UTC
please don't close bugs before the patch is in the tree
Comment 5 Daniel Black (RETIRED) gentoo-dev 2005-10-12 14:57:11 UTC
Martin thankyou. 1.2.4-r1 includes your patch.  
  
Can you submit your patch to the developers of dcfldd too please  
http://sourceforge.net/tracker/?group_id=115587&atid=672103  
  
AT's can you please test the 1.2.4-r1 specifically the md5 functionality as 
I've -amd64 masked the stable version. bad md5 generation in forensics package 
isn't really good at all. 
Comment 6 Martin Scharrer 2005-10-13 00:51:53 UTC
I was submiting my patch to the developers of dcfldd at sourceforge now.  
I send the patch already to the author Nicholas Harbour per e-mail on tuesday. 
Comment 7 Simon Stelling (RETIRED) gentoo-dev 2005-10-31 12:20:25 UTC
1.2.4-r1 works fine