summaryrefslogtreecommitdiffstats
path: root/libelf/elf32_getphdr.c
diff options
context:
space:
mode:
authorChih-Hung Hsieh <chh@google.com>2015-09-29 13:47:38 -0700
committerChih-Hung Hsieh <chh@google.com>2015-09-29 14:35:52 -0700
commitb67d33c44ca7c0d8709b9d729fb238f51008c50c (patch)
treead9113b82797fac924a0e474bcd6669dba47fcb8 /libelf/elf32_getphdr.c
parent56e6b652fa71abee20fe70c83829928df57d40b2 (diff)
parentd8698e55cbe95e56c3a4cbd67c320048ea4f087a (diff)
downloadandroid_external_elfutils-b67d33c44ca7c0d8709b9d729fb238f51008c50c.tar.gz
android_external_elfutils-b67d33c44ca7c0d8709b9d729fb238f51008c50c.tar.bz2
android_external_elfutils-b67d33c44ca7c0d8709b9d729fb238f51008c50c.zip
Merge in latest aosp/upstream-master d8698e55.
git merge d8698e55cbe95e56c3a4cbd67c320048ea4f087a Include upstream changes up to Wed Sep 23 20:44:06 2015. Update generated files: ./config.h ./libdw/known-dwarf.h ./version.h Change-Id: Ica2510edda846659a0c89703aeafe85bd62abab8
Diffstat (limited to 'libelf/elf32_getphdr.c')
-rw-r--r--libelf/elf32_getphdr.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/libelf/elf32_getphdr.c b/libelf/elf32_getphdr.c
index 1b82a480..99b4ac09 100644
--- a/libelf/elf32_getphdr.c
+++ b/libelf/elf32_getphdr.c
@@ -1,5 +1,5 @@
/* Get ELF program header table.
- Copyright (C) 1998-2010, 2014 Red Hat, Inc.
+ Copyright (C) 1998-2010, 2014, 2015 Red Hat, Inc.
This file is part of elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 1998.
@@ -46,8 +46,7 @@
#endif
ElfW2(LIBELFBITS,Phdr) *
-__elfw2(LIBELFBITS,getphdr_wrlock) (elf)
- Elf *elf;
+__elfw2(LIBELFBITS,getphdr_wrlock) (Elf *elf)
{
ElfW2(LIBELFBITS,Phdr) *result;
@@ -141,13 +140,20 @@ __elfw2(LIBELFBITS,getphdr_wrlock) (elf)
}
else
{
- if (ALLOW_UNALIGNED
- || ((uintptr_t) file_phdr
- & (__alignof__ (ElfW2(LIBELFBITS,Phdr)) - 1)) == 0)
+ bool copy = ! (ALLOW_UNALIGNED
+ || ((uintptr_t) file_phdr
+ & (__alignof__ (ElfW2(LIBELFBITS,Phdr))
+ - 1)) == 0);
+ if (! copy)
notcvt = file_phdr;
else
{
- notcvt = (ElfW2(LIBELFBITS,Phdr) *) alloca (size);
+ notcvt = (ElfW2(LIBELFBITS,Phdr) *) malloc (size);
+ if (unlikely (notcvt == NULL))
+ {
+ __libelf_seterrno (ELF_E_NOMEM);
+ goto out;
+ }
memcpy (notcvt, file_phdr, size);
}
@@ -162,6 +168,9 @@ __elfw2(LIBELFBITS,getphdr_wrlock) (elf)
CONVERT_TO (phdr[cnt].p_flags, notcvt[cnt].p_flags);
CONVERT_TO (phdr[cnt].p_align, notcvt[cnt].p_align);
}
+
+ if (copy)
+ free (notcvt);
}
}
}
@@ -227,8 +236,7 @@ __elfw2(LIBELFBITS,getphdr_wrlock) (elf)
}
ElfW2(LIBELFBITS,Phdr) *
-elfw2(LIBELFBITS,getphdr) (elf)
- Elf *elf;
+elfw2(LIBELFBITS,getphdr) (Elf *elf)
{
ElfW2(LIBELFBITS,Phdr) *result;