From: Matthias Klose Date: Sun, 18 Mar 2018 04:51:40 +0000 (+0000) Subject: pr22894 X-Git-Tag: archive/raspbian/2.30-8+rpi1^2~6 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=4be44720f5d0c5e7b7139482685948126c2dcf28;p=binutils.git pr22894 # DP: Fix potential integer overflow when reading corrupt dwarf1 From eef104664efb52965d85a28bc3fc7c77e52e48e2 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Wed, 28 Feb 2018 10:13:54 +0000 Subject: [PATCH] Fix potential integer overflow when reading corrupt dwarf1 debug information. PR 22894 * dwarf1.c (parse_die): Check the length of form blocks before advancing the data pointer. Gbp-Pq: Name pr22894.diff --- diff --git a/bfd/dwarf1.c b/bfd/dwarf1.c index 71bc57bfd..f272ea831 100644 --- a/bfd/dwarf1.c +++ b/bfd/dwarf1.c @@ -213,6 +213,7 @@ parse_die (bfd * abfd, /* Then the attributes. */ while (xptr + 2 <= aDiePtrEnd) { + unsigned int block_len; unsigned short attr; /* Parse the attribute based on its form. This section @@ -255,12 +256,24 @@ parse_die (bfd * abfd, break; case FORM_BLOCK2: if (xptr + 2 <= aDiePtrEnd) - xptr += bfd_get_16 (abfd, xptr); + { + block_len = bfd_get_16 (abfd, xptr); + if (xptr + block_len > aDiePtrEnd + || xptr + block_len < xptr) + return FALSE; + xptr += block_len; + } xptr += 2; break; case FORM_BLOCK4: if (xptr + 4 <= aDiePtrEnd) - xptr += bfd_get_32 (abfd, xptr); + { + block_len = bfd_get_32 (abfd, xptr); + if (xptr + block_len > aDiePtrEnd + || xptr + block_len < xptr) + return FALSE; + xptr += block_len; + } xptr += 4; break; case FORM_STRING: