#6 ed2k_hash 64-bit Compatibility Patch

Adam Dunn

This patch should fix operation of ed2k_hash on 64-bit
machines. Most 32-bit machines use ILP32 which means
int and long are both 32 bits, but IA64 and AMD64 use
LP64 which means int is 32 bits and long is 64 bits.
For more info, see

The md4.h header incorrectly made the assumption that
long is 4 bytes, which is not true on LP64 machines.
This patch makes the UINT4 type an int, which is 32
bits (4 bytes) on both ILP32 and LP64 systems. The
patch has been tested on AMD64 with gcc 4.0.3 without
error, and on x86 with gcc 4.0.4 without regression.

Further testing may be required before considering this
patch stable.

Note: This patch will fail on MIPS64 systems, as MIPS
uses ILP64. The code prior to this patch will fail on
MIPS64 as well.


  • Adam Dunn
    Adam Dunn

    Patch for AMD64 operation

    • status: open --> closed-fixed
  • Logged In: YES
    Originator: NO

    Hmm, only been 18 months - didn't know anyone still used ed2k/ed2k_hash. Didn't get notifications about the pending patches either. Oh well, fixed in CVS, sorry about that:

    2007-10-25 uberdork

    Patch by: Dominik Mierzejewski <dominik greysector net> and Adam Dunn

    * ed2k_hash/md4.c (MD4Init):
    * ed2k_hash/md4.h (PROTOTYPES, POINTER, UINT2, UINT4, UINT4):
    Fix bug in MD4 calculation on platforms where sizeof(long) != 4,
    ie. x86-64 and most other 64-bit platforms (fixes #1491834).

    * ed2k_hash/cl_ui.c:
    * ed2k_hash/options.c:
    Include <string.h> to avoid compiler warnings.