summaryrefslogtreecommitdiff
path: root/libdw
diff options
context:
space:
mode:
authorMark Wielaard <mjw@redhat.com>2013-11-09 16:45:22 +0100
committerMark Wielaard <mjw@redhat.com>2013-11-09 17:04:10 +0100
commit03d76f4aec5e750b81198c7a24571e119e754b40 (patch)
treec0e79f4440f74d1bd718ed95f85992f1744007ab /libdw
parent0b867460075c9f02cb305abc91a0e12b90017583 (diff)
downloadelfutils-03d76f4aec5e750b81198c7a24571e119e754b40.tar.gz
Fix some (harmless) cppcheck warnings.
[dwarf_getaranges.c:149]: (warning) Ineffective statement similar to '*A++;'. Did you intend to write '(*A)++;'? There was already an XXX statement that we weren't using the result. Explicitly read the segment_size and check it is zero. And report an error if it isn't, since we aren't prepared to handle such a case. [arlib.c:62]: (error) Uninitialized variable: tmpbuf [arlib.c:124]: (error) Uninitialized variable: tmpbuf cppcheck is wrong. tmpbuf is initialized in the snprintf call whose result is use in the same memcpy call. It does make the code less readable and harder to understand. So explicitly split the snprintf and memcpy calls. [nm.c:766]: (warning) Assert statement modifies 'cnt'. The cnt variable was only used for this assert sanity check. But it is bad style to do have side effects inside an assert statement. Increase cnt after the assert. Reported-by: David Binderman <dcb314@hotmail.com> Signed-off-by: Mark Wielaard <mjw@redhat.com>
Diffstat (limited to 'libdw')
-rw-r--r--libdw/ChangeLog5
-rw-r--r--libdw/dwarf_getaranges.c7
2 files changed, 9 insertions, 3 deletions
diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index c355c306..dc0c4c90 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,3 +1,8 @@
+2013-11-09 Mark Wielaard <mjw@redhat.com>
+
+ * dwarf_getaranges.c (dwarf_getaranges): Read segment_size and
+ check that it is zero.
+
2013-11-07 Jan Kratochvil <jan.kratochvil@redhat.com>
* cfi.h (struct Dwarf_Frame_s): Make the comment more specific.
diff --git a/libdw/dwarf_getaranges.c b/libdw/dwarf_getaranges.c
index cc70cb21..20ac7ec6 100644
--- a/libdw/dwarf_getaranges.c
+++ b/libdw/dwarf_getaranges.c
@@ -144,9 +144,10 @@ dwarf_getaranges (dbg, aranges, naranges)
if (address_size != 4 && address_size != 8)
goto invalid;
- /* Ignore the segment size value. */
- // XXX Really?
- (void) *readp++;
+ /* We don't actually support segment selectors. */
+ unsigned int segment_size = *readp++;
+ if (segment_size != 0)
+ goto invalid;
/* Round the address to the next multiple of 2*address_size. */
readp += ((2 * address_size - ((readp - hdrstart) % (2 * address_size)))