Fix gcc -fsanitize=nonnull-attribute issues

Mark Wielaard mjw at redhat.com
Sun May 31 15:51:48 UTC 2015


GCC 5.1 includes -fsanitize=nonnull-attribute in -fsanitize=undefined.
This showed a couple of places where we were passing a NULL argument
to functions not expecting them. Even though these functions might not
actually use the argument (if for example the size argument of a buffer
is zero), gcc might use the information to assume the passed in variables
are always nonnull, which might cause unexpected optimizations.

 libdwfl: Check file_name is not NULL before calling canonicalize_file_name.
 libelf: Don't call mempcpy with possible NULL d_buf.
 libelf: Don't call memmove with possible NULL buffer.
 elfcmp: Don't call memcmp with possible NULL d_buf.


More information about the elfutils-devel mailing list