You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
2.4 KiB
67 lines
2.4 KiB
diff --git a/src/readelf.c b/src/readelf.c |
|
index 1f4d1f4..05ec736 100644 |
|
--- a/src/readelf.c |
|
+++ b/src/readelf.c |
|
@@ -327,7 +327,7 @@ dophn_core(struct magic_set *ms, int clazz, int swap, int fd, off_t off, |
|
* Loop through all the program headers. |
|
*/ |
|
for ( ; num; num--) { |
|
- if (pread(fd, xph_addr, xph_sizeof, off) == -1) { |
|
+ if (pread(fd, xph_addr, xph_sizeof, off) < (ssize_t)xph_sizeof) { |
|
file_badread(ms); |
|
return -1; |
|
} |
|
@@ -869,6 +869,7 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num, |
|
uint64_t cap_hw1 = 0; /* SunOS 5.x hardware capabilites */ |
|
uint64_t cap_sf1 = 0; /* SunOS 5.x software capabilites */ |
|
char name[50]; |
|
+ ssize_t namesize; |
|
|
|
if (size != xsh_sizeof) { |
|
if (file_printf(ms, ", corrupted section header size") == -1) |
|
@@ -877,7 +878,7 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num, |
|
} |
|
|
|
/* Read offset of name section to be able to read section names later */ |
|
- if (pread(fd, xsh_addr, xsh_sizeof, off + size * strtab) == -1) { |
|
+ if (pread(fd, xsh_addr, xsh_sizeof, off + size * strtab) < (ssize_t)xsh_sizeof) { |
|
file_badread(ms); |
|
return -1; |
|
} |
|
@@ -885,15 +886,15 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num, |
|
|
|
for ( ; num; num--) { |
|
/* Read the name of this section. */ |
|
- if (pread(fd, name, sizeof(name), name_off + xsh_name) == -1) { |
|
+ if ((namesize = pread(fd, name, sizeof(name) - 1, name_off + xsh_name)) == -1) { |
|
file_badread(ms); |
|
return -1; |
|
} |
|
- name[sizeof(name) - 1] = '\0'; |
|
+ name[namesize] = '\0'; |
|
if (strcmp(name, ".debug_info") == 0) |
|
stripped = 0; |
|
|
|
- if (pread(fd, xsh_addr, xsh_sizeof, off) == -1) { |
|
+ if (pread(fd, xsh_addr, xsh_sizeof, off) < (ssize_t)xsh_sizeof) { |
|
file_badread(ms); |
|
return -1; |
|
} |
|
@@ -923,7 +924,7 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num, |
|
" for note"); |
|
return -1; |
|
} |
|
- if (pread(fd, nbuf, xsh_size, xsh_offset) == -1) { |
|
+ if (pread(fd, nbuf, xsh_size, xsh_offset) < (ssize_t)xsh_size) { |
|
file_badread(ms); |
|
free(nbuf); |
|
return -1; |
|
@@ -1076,7 +1077,7 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off, |
|
} |
|
|
|
for ( ; num; num--) { |
|
- if (pread(fd, xph_addr, xph_sizeof, off) == -1) { |
|
+ if (pread(fd, xph_addr, xph_sizeof, off) < (ssize_t)xph_sizeof) { |
|
file_badread(ms); |
|
return -1; |
|
}
|
|
|