Fix an undefined behaviour in the BFD library's DWARF parser.

PR 28687
	* dwarf1.c (parse_die): Fix undefined behaviour in range tests.
This commit is contained in:
Nikita Popov 2021-12-15 17:49:06 +00:00 committed by Nick Clifton
parent 161e87d121
commit 4d3605c8ca
2 changed files with 7 additions and 4 deletions

View File

@ -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

View File

@ -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;
}