md5sum makes unaligned word accesses...

Rob Landley rob at landley.net
Thu May 11 16:22:10 UTC 2006


On Thursday 11 May 2006 2:05 am, Andre wrote:
> Anyway, comparing the faulting PC with a disassembly of busybox, it
> looks like the fault happens in md5_hash_block()
>
> void md5_hash_block(const void *buffer, size_t len, md5_ctx_t *ctx)
> {
>     uint32_t correct_words[16];
>     const uint32_t *words = buffer;
>     ....
>
> Casting a void * to an unsigned int * is highly suspect unless all
> callers of md5_has_block() somehow know that 'buffer' has implicit
> alignment constraints...

But it doesn't on any other platform.

Looks like we need to add some thing like this to plaform.h:

#ifdef __arm__
#define alignint(x, y) memcpy(x,y,sizeof(int))
#else
#define alignint(x, y) x = y;
#endif

And then use that, unless there's some way to tell gcc "Hey!  Potentially 
unaligned access!  Produce the appropriate assembly if necessary, you 
twit..."  Some kind of attribute __maybe_unaligned__...  (Doesn't the linux 
kernel have some kind of macro for this, or something?)

I'd like to add a mention of this to the programming section of the FAQ once 
this is resolved...

> Andre

Rob
-- 
Never bet against the cheap plastic solution.



More information about the busybox mailing list