[redland-dev] Digests, Endianness and Bit Order

simon at sanbi.ac.za simon at sanbi.ac.za
Sun Apr 17 22:55:14 BST 2005


Ping,

The code in my small test program was snarfed from the Redland MySQL
storage engine which is where I originally encountered the problem (a
storage created by an i386 machine was inaccessible from a PPC machine). 
I'm currently not at my development machine but I'm pretty sure the MySQL
storage hash function suffers from the same bugs as my test case.  Will
check and email again later today.

Thanks once again for the help. :)

> Bug (1) - minor one.  If you use sizeof like that on a string it adds
> the \0 into the length, so you can't check the MD5sum is right with
>
>   $ echo -n 'foobar' | md5sum
>   3858f62230ac3c915f300c664312c63f  -
>
> Bug (2) - serious.  This is not a portable way to use the first 4
> bytes of the digest.  When you memcpy into a u_int64_t, that will not
> work across different endian systems to calculate the same value.
> Instead, you need to do something like:

Schiavo
Simon



More information about the redland-dev mailing list