summaryrefslogtreecommitdiff
path: root/elf.c
diff options
context:
space:
mode:
Diffstat (limited to 'elf.c')
-rw-r--r--elf.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/elf.c b/elf.c
index 2a73ce3..f0240dc 100644
--- a/elf.c
+++ b/elf.c
@@ -112,7 +112,7 @@ read_elf_body ()
FILE *fp = efile.fp;
fseek (fp, ehdr.e_shoff + ((ehdr.e_shstrndx) * ehdr.e_shentsize), SEEK_SET);
- if (fread (&ssh, sizeof (ssh), 1, fp) != 1)
+ if ((!fp) || (fread (&ssh, sizeof (ssh), 1, fp) != 1))
{
return (-1);
}
@@ -217,26 +217,23 @@ read_elf_body ()
}
int
-elf_load (char *fname, int readsym)
+elf_load (char *fname, int load)
{
FILE *fp;
int res;
- if (!readsym)
+ if ((fp = fopen (fname, "r")) == NULL)
{
- if ((fp = fopen (fname, "r")) == NULL)
- {
- printf ("file not found\n");
- return (-1);
- }
+ printf ("file not found\n");
+ return (-1);
+ }
- res = read_elf_header (fp);
- if (res < 0)
- printf ("File read error\n");
+ res = read_elf_header (fp);
+ if (res < 0)
+ printf ("File read error\n");
- }
- else
+ if (load && (res >= 0))
{
res = read_elf_body ();
if (res < 0)