summaryrefslogtreecommitdiffstats
path: root/libdw/dwarf_formstring.c
diff options
context:
space:
mode:
authorAleksei Vetrov <[email protected]>2023-11-16 21:29:22 +0000
committerMark Wielaard <[email protected]>2023-11-17 16:30:01 +0100
commit1bd9deb9aa19ac2e2fa9665009e0d5924adcf4d3 (patch)
treebf4ff276e385bc90324f6b760f93c1e49d7c0a42 /libdw/dwarf_formstring.c
parentfce0ec4f830fde7c536202f3443e455035c88b3a (diff)
libdw: check offset dwarf_formstring in all cases
This check was initially added to test if offset overflows the safe prefix where any string will be null-terminated. However the check was placed in a wrong place and didn't cover all `attrp->form` cases. * libdw/dwarf_formstring.c (dwarf_formstring): Move offset check right before returning the result. Signed-off-by: Aleksei Vetrov <[email protected]>
Diffstat (limited to 'libdw/dwarf_formstring.c')
-rw-r--r--libdw/dwarf_formstring.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/libdw/dwarf_formstring.c b/libdw/dwarf_formstring.c
index 0ee42411..65f03a5e 100644
--- a/libdw/dwarf_formstring.c
+++ b/libdw/dwarf_formstring.c
@@ -173,11 +173,11 @@ dwarf_formstring (Dwarf_Attribute *attrp)
off = read_4ubyte_unaligned (dbg, datap);
else
off = read_8ubyte_unaligned (dbg, datap);
-
- if (off >= data_size)
- goto invalid_offset;
}
+ if (off >= data_size)
+ goto invalid_offset;
+
return (const char *) data->d_buf + off;
}
INTDEF(dwarf_formstring)