summaryrefslogtreecommitdiff
path: root/libelf/elf32_newphdr.c
diff options
context:
space:
mode:
Diffstat (limited to 'libelf/elf32_newphdr.c')
-rw-r--r--libelf/elf32_newphdr.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/libelf/elf32_newphdr.c b/libelf/elf32_newphdr.c
index 1db20806..01038e73 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 <drepper@redhat.com>, 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) *)