summaryrefslogtreecommitdiffstats
path: root/libelf/elf32_getshdr.c
diff options
context:
space:
mode:
Diffstat (limited to 'libelf/elf32_getshdr.c')
-rw-r--r--libelf/elf32_getshdr.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/libelf/elf32_getshdr.c b/libelf/elf32_getshdr.c
index 1e26e854..cf7a41fd 100644
--- a/libelf/elf32_getshdr.c
+++ b/libelf/elf32_getshdr.c
@@ -20,8 +20,10 @@
#endif
#include <assert.h>
+#include <errno.h>
#include <unistd.h>
+#include <system.h>
#include "libelfP.h"
#include "common.h"
@@ -122,12 +124,13 @@ elfw2(LIBELFBITS,getshdr) (scn)
CONVERT_TO (shdr[cnt].sh_entsize, notcvt[cnt].sh_entsize);
}
}
- else if (elf->fildes != -1)
+ else if (likely (elf->fildes != -1))
{
/* Read the header. */
- if ((size_t) pread (elf->fildes,
- elf->state.ELFW(elf,LIBELFBITS).shdr, size,
- elf->start_offset + ehdr->e_shoff) != size)
+ ssize_t n = pread_retry (elf->fildes,
+ elf->state.ELFW(elf,LIBELFBITS).shdr, size,
+ elf->start_offset + ehdr->e_shoff);
+ if (unlikely ((size_t) n != size))
{
/* Severe problems. We cannot read the data. */
__libelf_seterrno (ELF_E_READ_ERROR);