The char* here isn't 4 byte aligned so the cast to int32_t* can
create an unaligned access.
Replace with a memcpy.
Differential D128491
[test-suite] Fix unaligned uint32_t accesses in ClamAV. craig.topper on Jun 23 2022, 9:37 PM. Authored by
Details The char* here isn't 4 byte aligned so the cast to int32_t* can Replace with a memcpy.
Diff Detail
Event TimelineComment Actions LGTM, but at the same time, I have no idea whether we're *supposed* to make changes to the source code for these projects or not (my understanding is that they're real world code and so we don't want to change the source code because then it's not reflective of real world code any longer, but I could be totally wrong). Comment Actions FWIW the current ClamAV repo uses a packed union to convert to int32 and has for 14 years. https://github.com/Cisco-Talos/clamav/blob/62bf3bea329a13d8416d72d289f72bba3e5a1933/libclamav/others.h It looks like the copy in llvm-test-suite was created 15 years ago. Comment Actions LGTM, since the upstream has fixed it, even in a different way. A misaligned access would manifest as a -fsanitize=alignment failure. llvm test suite can be useful to benchmark sanitizers. |