Skip to content

Conversation

@daviesrob
Copy link
Member

UBSan on clang complains about dereferencing unaligned uint16_tpointers even when the dereference is being done by memmove(). Strictly it's correct as even setting the pointer to such a value is undefined behaviour according to the standard.

Silence the noise by changing the pointers to uint8_t and adjusting the arithmetic on them as necessary.

Some bounds checks to ensure fast code won't read beyond the end of its input are also adjusted to prevent any possibility of generating an address beyond the limits of the input memory.

(configure CFLAGS='-g -O2 -fsanitize=address,undefined -fno-sanitize-recover=all' LDFLAGS='-g -O2 -fsanitize=address,undefined' to highlight the problem this solves.)

UBSan on clang complains about dereferencing unaligned uint16_t
pointers even when the dereference is being done by memmove().
Strictly it's correct as even setting the pointer to such a
value is undefined behaviour according to the standard.

Silence the noise by changing the pointers to uint8_t and
adjusting the arithmetic on them as necessary.

Some bounds checks to ensure fast code won't read beyond the
end of its input are also adjusted to prevent any possibility
of generating an address beyond the limits of the input memory.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant