Skip to content

Commit 1da441c

Browse files
libbacktrace: correct buffer overflow tests
* dwarf.c (resolve_string): Use > rather than >= to check whether string index extends past buffer. (resolve_addr_index): Similarly for address index.
1 parent f24e9f4 commit 1da441c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

dwarf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,7 +1386,7 @@ resolve_string (const struct dwarf_sections *dwarf_sections, int is_dwarf64,
13861386

13871387
offset = val->u.uint * (is_dwarf64 ? 8 : 4) + str_offsets_base;
13881388
if (offset + (is_dwarf64 ? 8 : 4)
1389-
>= dwarf_sections->size[DEBUG_STR_OFFSETS])
1389+
> dwarf_sections->size[DEBUG_STR_OFFSETS])
13901390
{
13911391
error_callback (data, "DW_FORM_strx value out of range", 0);
13921392
return 0;
@@ -1430,7 +1430,7 @@ resolve_addr_index (const struct dwarf_sections *dwarf_sections,
14301430
struct dwarf_buf addr_buf;
14311431

14321432
offset = addr_index * addrsize + addr_base;
1433-
if (offset + addrsize >= dwarf_sections->size[DEBUG_ADDR])
1433+
if (offset + addrsize > dwarf_sections->size[DEBUG_ADDR])
14341434
{
14351435
error_callback (data, "DW_FORM_addrx value out of range", 0);
14361436
return 0;

0 commit comments

Comments
 (0)