summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey A. Chernov <ache@FreeBSD.org>2000-12-15 13:20:43 +0000
committerAndrey A. Chernov <ache@FreeBSD.org>2000-12-15 13:20:43 +0000
commite6f0df2b205a873c4a828ea1277c5b5218cd55b0 (patch)
tree2296110a071f767698de5453fcf37a6564221653
parent874d21b468347a45791ef9ee197daf62563e75de (diff)
Notes
-rw-r--r--usr.bin/ldd/ldd.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/usr.bin/ldd/ldd.c b/usr.bin/ldd/ldd.c
index e272b6b3a257..cf9ebde6fc35 100644
--- a/usr.bin/ldd/ldd.c
+++ b/usr.bin/ldd/ldd.c
@@ -145,21 +145,24 @@ char *argv[];
Elf_Phdr phdr;
int dynamic = 0, i;
- lseek(fd, 0, SEEK_SET);
- if (read(fd, &ehdr, sizeof ehdr) != sizeof ehdr) {
+ if (lseek(fd, 0, SEEK_SET) == -1 ||
+ read(fd, &ehdr, sizeof ehdr) != sizeof ehdr ||
+ lseek(fd, ehdr.e_phoff, SEEK_SET) == -1
+ ) {
warnx("%s: can't read program header", *argv);
file_ok = 0;
- }
- lseek(fd, 0, ehdr.e_phoff);
- for (i = 0; i < ehdr.e_phnum; i++) {
- if (read(fd, &phdr, ehdr.e_phentsize)
- != sizeof phdr) {
- warnx("%s: can't read program header",
- *argv);
- file_ok = 0;
+ } else {
+ for (i = 0; i < ehdr.e_phnum; i++) {
+ if (read(fd, &phdr, ehdr.e_phentsize)
+ != sizeof phdr) {
+ warnx("%s: can't read program header",
+ *argv);
+ file_ok = 0;
+ break;
+ }
+ if (phdr.p_type == PT_DYNAMIC)
+ dynamic = 1;
}
- if (phdr.p_type == PT_DYNAMIC)
- dynamic = 1;
}
if (!dynamic) {
warnx("%s: not a dynamic executable", *argv);