• Mark Fasheh's avatar
    Fix unaligned access in murmur3_add_to_running_checksum() · c1179ccf
    Mark Fasheh authored
    We were casting the digest (a char array) out to a uint64_t array and
    derefing elements from it into our temporary variables. If the digest is not
    properly aligned (which happens when we're using a hashfile), the results are
    undefined. memcpy() instead.
    
    This fixes the following runtime errors (reproduced by building with
    -fsanitize=undefined and running with a hashfile):
    
    csum-murmur3.c:139:12: runtime error: load of misaligned address
    0x7f348400116c for type 'uint64_t', which requires 8 byte alignment
    0x7f348400116c: note: pointer points here
      00 00 00 00 21 ae da 93  a1 d6 44 d1 35 2d 9e 2a  04 7a 5c bc 00 00 00 00
     00 00 00 00 00 00 00 00
                  ^
    csum-murmur3.c:140:12: runtime error: load of misaligned address
     0x7f348400116c for type 'uint64_t', which requires 8 byte alignment
    0x7f348400116c: note: pointer points here
      00 00 00 00 21 ae da 93  a1 d6 44 d1 35 2d 9e 2a  04 7a 5c bc 00 00 00 00
     00 00 00 00 00 00 00 00
    
    Thanks very much to Matthias Krüger for pointing this (and other issues)
    out.
    Signed-off-by: 's avatarMark Fasheh <mfasheh@suse.de>
    c1179ccf