From: Nick Clifton Date: Fri, 28 Apr 2017 10:21:53 +0000 (+0100) Subject: Fix heap-buffer address violation when reading version data from a corrupt binary. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4e3afec278d1fb55b983751d02119f65566bd094;p=binutils-gdb.git Fix heap-buffer address violation when reading version data from a corrupt binary. PR binutils/21437 * readelf.c (process_version_sections): Check for underflow when computing the start address of the auxillary version data. --- diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 951673bd6ad..8bb1fc5052e 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,9 @@ +2017-04-28 Nick Clifton + + PR binutils/21437 + * readelf.c (process_version_sections): Check for underflow when + computing the start address of the auxillary version data. + 2017-04-28 Nick Clifton PR binutils/21438 diff --git a/binutils/readelf.c b/binutils/readelf.c index b57e1e029bd..72f9dda6443 100644 --- a/binutils/readelf.c +++ b/binutils/readelf.c @@ -10178,8 +10178,9 @@ process_version_sections (FILE * file) printf (_(" Index: %d Cnt: %d "), ent.vd_ndx, ent.vd_cnt); - /* Check for overflow. */ - if (ent.vd_aux + sizeof (* eaux) > (size_t) (endbuf - vstart)) + /* Check for overflow and underflow. */ + if (ent.vd_aux + sizeof (* eaux) > (size_t) (endbuf - vstart) + || (vstart + ent.vd_aux < vstart)) break; vstart += ent.vd_aux;