aboutsummaryrefslogtreecommitdiff
path: root/linux-user/gen-vdso.c
diff options
context:
space:
mode:
Diffstat (limited to 'linux-user/gen-vdso.c')
-rw-r--r--linux-user/gen-vdso.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/linux-user/gen-vdso.c b/linux-user/gen-vdso.c
index fce9d5c..aeaa927 100644
--- a/linux-user/gen-vdso.c
+++ b/linux-user/gen-vdso.c
@@ -113,9 +113,21 @@ int main(int argc, char **argv)
* We expect the vdso to be small, on the order of one page,
* therefore we do not expect a partial read.
*/
- fseek(inf, 0, SEEK_END);
+ if (fseek(inf, 0, SEEK_END) < 0) {
+ goto perror_inf;
+ }
total_len = ftell(inf);
- fseek(inf, 0, SEEK_SET);
+ if (total_len < 0) {
+ goto perror_inf;
+ }
+ if (fseek(inf, 0, SEEK_SET) < 0) {
+ goto perror_inf;
+ }
+
+ if (total_len < EI_NIDENT) {
+ fprintf(stderr, "%s: file too small (truncated?)\n", inf_name);
+ return EXIT_FAILURE;
+ }
buf = malloc(total_len);
if (buf == NULL) {