The bitcollider tool core dumps occasionally on my
system (OpenBSD 3.4, i386). There are certain files,
always mp3s, that it doesn't like. It turns out that
the mp3-specific fingerprint code occasionally reads
past the end of the buffer when it's filling in the
audioShaExtra field. If the buffer is allocated right
at the end of the VM region, then the tool will
segfault.
This patch fixes that; it's careful not to copy from
past the end of the buffer. Since the same logic
occurs after each call to update_audio_sha1(), I
simply moved it into that function.
I also got rid of the unportable casting of pointers
to (unsigned) for arithemtic purposes --- pointers
don't necessarily fit into ints, and pointer
arithmetic is defined to have the desired behavior in
this situation anyway, so it's better just to avoid
teh cast.
Patch to avoid reading past end of buffer