Author: emaste
Date: Wed Dec 31 01:48:23 2014
New Revision: 276443
URL: https://svnweb.freebsd.org/changeset/base/276443

Log:
  libelf: Rearrange size test to prevent integer overflow
  
  Sponsored by: The FreeBSD Foundation

Modified:
  head/contrib/elftoolchain/libelf/elf_scn.c

Modified: head/contrib/elftoolchain/libelf/elf_scn.c
==============================================================================
--- head/contrib/elftoolchain/libelf/elf_scn.c  Wed Dec 31 01:38:02 2014        
(r276442)
+++ head/contrib/elftoolchain/libelf/elf_scn.c  Wed Dec 31 01:48:23 2014        
(r276443)
@@ -62,7 +62,7 @@ _libelf_load_section_headers(Elf *e, voi
 #define        CHECK_EHDR(E,EH)        do {                            \
                if (fsz != (EH)->e_shentsize ||                 \
                    shnum > SIZE_MAX / fsz ||                   \
-                   shoff + fsz * shnum > e->e_rawsize) {       \
+                   fsz * shnum > e->e_rawsize - shoff) {       \
                        LIBELF_SET_ERROR(HEADER, 0);            \
                        return (0);                             \
                }                                               \
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to