diff options
author | Nikita Popov <npv1310@gmail.com> | 2021-12-15 17:49:06 +0000 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2021-12-15 17:49:23 +0000 |
commit | 4d3605c8ca92bcde848581a8ec031827c798501b (patch) | |
tree | 63089de59f569a0768bb852ce6e8bc6e7ffb934c /bfd | |
parent | 161e87d12167b1e36193385485c1f6ce92f74f02 (diff) | |
download | gdb-4d3605c8ca92bcde848581a8ec031827c798501b.zip gdb-4d3605c8ca92bcde848581a8ec031827c798501b.tar.gz gdb-4d3605c8ca92bcde848581a8ec031827c798501b.tar.bz2 |
Fix an undefined behaviour in the BFD library's DWARF parser.
PR 28687
* dwarf1.c (parse_die): Fix undefined behaviour in range tests.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 5 | ||||
-rw-r--r-- | bfd/dwarf1.c | 6 |
2 files changed, 7 insertions, 4 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 35b659b..2431171 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +2021-12-15 Nikita Popov <npv1310@gmail.com> + + PR 28687 + * dwarf1.c (parse_die): Fix undefined behaviour in range tests. + 2021-11-17 Nick Clifton <nickc@redhat.com> PR 28452 diff --git a/bfd/dwarf1.c b/bfd/dwarf1.c index f1c4e7e..9f46655 100644 --- a/bfd/dwarf1.c +++ b/bfd/dwarf1.c @@ -258,8 +258,7 @@ parse_die (bfd * abfd, if (xptr + 2 <= aDiePtrEnd) { block_len = bfd_get_16 (abfd, xptr); - if (xptr + block_len > aDiePtrEnd - || xptr + block_len < xptr) + if ((unsigned int) (aDiePtrEnd - xptr) < block_len) return false; xptr += block_len; } @@ -269,8 +268,7 @@ parse_die (bfd * abfd, if (xptr + 4 <= aDiePtrEnd) { block_len = bfd_get_32 (abfd, xptr); - if (xptr + block_len > aDiePtrEnd - || xptr + block_len < xptr) + if ((unsigned int) (aDiePtrEnd - xptr) < block_len) return false; xptr += block_len; } |