View Issue Details

IDProjectCategoryView StatusLast Update
0000413LDMud 3.3Compilation, Installationpublic2018-01-29 22:57
Reporterranger Assigned Tolars 
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
Product Version3.3 
Fixed in Version3.3 
Summary0000413: md5() misbehavior on AMD x86 64 Bit Systems
Descriptionmd5("hello")

reports on our system:
7891e72e0c42461f87025d544bb2d4cb

should correctly report:
5d41402abc4b2a76b9719d911017c592

I am not sure, if I compiled something wrong, but I don't think so.
amy ideas?
Additional Informationbash:/> uname -a
Linux www 2.6.13-gentoo-r5 0000001 Tue Nov 8 16:42:08 CET 2005 x86_64 AMD Sempron(tm) Processor 3000+ AuthenticAMD GNU/Linux

bash:/> cat /proc/cpuinfo
processor : 0
vendor_id : AuthenticAMD
cpu family : 15
model : 44
model name : AMD Sempron(tm) Processor 3000+
stepping : 2
cpu MHz : 1799.861
cache size : 128 KB
fpu : yes
fpu_exception : yes
cpuid level : 1
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx mmxext fxsr_opt lm 3dnowext 3dnow pni lahf_lm
bogomips : 3608.40
TLB size : 1024 4K pages
clflush size : 64
cache_alignment : 64
address sizes : 40 bits physical, 48 bits virtual
power management: ts fid vid ttp tm stc

TagsNo tags attached.

Activities

ranger

2005-11-11 09:48

reporter   ~0000400

Sorry, I selected the wrong cathegory. It should be "efuns" of course.

fufu

2005-11-11 14:13

manager   ~0000401

As far as I can see it should suffice to replace
  #define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
in md5.c with
  #define ROTATE_LEFT(x, n) (((x) << (n)) | (((x) & 0xffffffffUL)) >> (32-(n))))
so no garbage bits like carries or leftovers from previous rotates are or-ed into the relevant bits of the result in this operation.

BTW, I think that all md5 related constants in that code should have a UL suffix; that would allow it to compile and work correctly on systems with 16 bit ints. Is this relevant for ldmud?

fufu

2005-11-11 14:41

manager   ~0000402

As Gawain@Regenbogen pointed out, there's a ) too much in my fix, it should be:
  #define ROTATE_LEFT(x, n) (((x) << (n)) | (((x) & 0xffffffffUL) >> (32-(n))))
Gawain also said that the code works fine with that change.

ranger

2005-11-16 10:01

reporter   ~0000404

The replacement fixes our issue perfectly. Thanks a lot!

lars

2005-11-24 12:28

reporter   ~0000411

I implemented the patch - thanks!
It will be in 3.3.712 and 3.2.12

Issue History

Date Modified Username Field Change
2005-11-11 09:46 ranger New Issue
2005-11-11 09:48 ranger Note Added: 0000400
2005-11-11 14:13 fufu Note Added: 0000401
2005-11-11 14:41 fufu Note Added: 0000402
2005-11-16 10:01 ranger Note Added: 0000404
2005-11-24 12:28 lars Status new => resolved
2005-11-24 12:28 lars Fixed in Version => 3.3
2005-11-24 12:28 lars Resolution open => fixed
2005-11-24 12:28 lars Assigned To => lars
2005-11-24 12:28 lars Note Added: 0000411
2006-02-28 21:04 lars Status resolved => closed
2010-11-16 10:42 lars Source_changeset_attached => ldmud.git master 8da8f48a
2010-11-16 10:42 lars Source_changeset_attached => ldmud.git master-3.2 76db098a
2018-01-29 19:59 lars Source_changeset_attached => ldmud.git master 8da8f48a
2018-01-29 19:59 lars Source_changeset_attached => ldmud.git master-3.2 76db098a
2018-01-29 22:57 lars Source_changeset_attached => ldmud.git master 8da8f48a
2018-01-29 22:57 lars Source_changeset_attached => ldmud.git master-3.2 76db098a