diff options
author | Mark Wielaard <mark@klomp.org> | 2021-12-04 01:08:48 +0100 |
---|---|---|
committer | Mark Wielaard <mark@klomp.org> | 2021-12-09 00:11:36 +0100 |
commit | 3e1e249bfd8455457716cce798f3f91d01f2f00d (patch) | |
tree | 470a814ca962773121010673487ed9db692d2a64 /src/ChangeLog | |
parent | 00d1c798b5225af732ecace438d4895ce6d6d24e (diff) | |
download | elfutils-3e1e249bfd8455457716cce798f3f91d01f2f00d.tar.gz |
readelf: Workaround stringop-truncation error
In function ‘strncpy’,
inlined from ‘print_ehdr’ at readelf.c:1175:4:
error: ‘__builtin_strncpy’ specified bound 512 equals destination size
[-Werror=stringop-truncation]
strncpy doesn't terminate the copied string if there is not enough
room. We compensate later by explicitly adding a zero terminator at
buf[sizeof (buf) - 1]. Normally gcc does see this, but with
-fsanitize=address there is too much (checking) code in between. But
it is actually better to not let strncpy do too much work, so
substract one from the size.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Diffstat (limited to 'src/ChangeLog')
-rw-r--r-- | src/ChangeLog | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 05b2522d..263e9faa 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2021-12-04 Mark Wielaard <mark@klomp.org> + + * readelf.c (print_ehdr): Pass sizeof (buf) - 1 to strncpy. + 2021-10-20 John M Mellor-Crummey <johnmc@rice.edu> * readelf.c (print_debug_line_section): Try to read |