X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=libelf%2Felf32_newphdr.c;h=01038e733c65da1ff89d9058fc4da8396db0952a;hb=a286dd013ef8d46edf013efc0908822a59d8ac81;hp=1db208066626590a8558db0e0bb335a42057f03b;hpb=18a667176dd196f7bc3a9cdf1cbd87d4c7b31c7f;p=platform%2Fupstream%2Felfutils.git diff --git a/libelf/elf32_newphdr.c b/libelf/elf32_newphdr.c index 1db2080..01038e7 100644 --- a/libelf/elf32_newphdr.c +++ b/libelf/elf32_newphdr.c @@ -1,5 +1,5 @@ /* Create new ELF program header table. - Copyright (C) 1999-2010 Red Hat, Inc. + Copyright (C) 1999-2010, 2014 Red Hat, Inc. This file is part of elfutils. Written by Ulrich Drepper , 1998. @@ -114,6 +114,12 @@ elfw2(LIBELFBITS,newphdr) (elf, count) || count == PN_XNUM || elf->state.ELFW(elf,LIBELFBITS).phdr == NULL) { + if (unlikely (count > SIZE_MAX / sizeof (ElfW2(LIBELFBITS,Phdr)))) + { + result = NULL; + goto out; + } + /* Allocate a new program header with the appropriate number of elements. */ result = (ElfW2(LIBELFBITS,Phdr) *)