version 1.23, 2004/01/14 04:23:26 |
version 1.24, 2004/04/29 13:34:37 |
|
|
union hdr exec_head; |
union hdr exec_head; |
FILE *fp; |
FILE *fp; |
int retval; |
int retval; |
|
size_t bytes; |
char magic[SARMAG]; |
char magic[SARMAG]; |
|
|
if (!(fp = fopen(fname, "r"))) { |
if (!(fp = fopen(fname, "r"))) { |
|
|
* first check whether this is an object file - read a object |
* first check whether this is an object file - read a object |
* header, and skip back to the beginning |
* header, and skip back to the beginning |
*/ |
*/ |
if (fread((char *)&exec_head, sizeof(exec_head), (size_t)1, fp) != 1) { |
bzero(&exec_head, sizeof(exec_head)); |
warnx("%s: bad format", fname); |
bytes = fread((char *)&exec_head, 1, sizeof(exec_head), fp); |
(void)fclose(fp); |
if (bytes < sizeof(exec_head)) { |
return(1); |
if (bytes < sizeof(exec_head.aout) || IS_ELF(exec_head.elf)) { |
|
warnx("%s: bad format", fname); |
|
(void)fclose(fp); |
|
return(1); |
|
} |
} |
} |
rewind(fp); |
rewind(fp); |
|
|