diff options
Diffstat (limited to 'exec')
-rw-r--r-- | exec/Makefile | 12 | ||||
-rw-r--r-- | exec/exec.c | 50 | ||||
-rw-r--r-- | exec/hashexec.c | 8 |
3 files changed, 48 insertions, 22 deletions
diff --git a/exec/Makefile b/exec/Makefile index 9b318e8a..e7050c10 100644 --- a/exec/Makefile +++ b/exec/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 1993,94,95,96,98,99,2000,01,02 Free Software Foundation, Inc. +# Copyright (C) 1993,94,95,96,98,99,2000,01,02,10 Free Software Foundation, Inc. # This file is part of the GNU Hurd. # # The GNU Hurd is free software; you can redistribute it and/or modify @@ -18,12 +18,16 @@ dir := exec makemode := server -SRCS = exec.c main.c hashexec.c hostarch.c unzip.c util.c inflate.c +SRCS = exec.c main.c hashexec.c hostarch.c \ + $(gzip-sources) $(bzip2-sources) OBJS = main.o hostarch.o exec.o hashexec.o \ execServer.o exec_startupServer.o \ $(gzip-objects) $(bzip2-objects) -gzip-objects = unzip.o util.o inflate.o -bzip2-objects = do-bunzip2.o +gzip-sources = unzip.c util.c inflate.c +gzip-objects = $(gzip-sources:%.c=%.o) +bzip2-sources = do-bunzip2.c +bzip2-objects = $(bzip2-sources:%.c=%.o) + LCLHDRS = gzip.h crypt.h tailor.h priv.h execmutations.h target = exec #targets = exec exec.static diff --git a/exec/exec.c b/exec/exec.c index cb3d7418..25628d79 100644 --- a/exec/exec.c +++ b/exec/exec.c @@ -233,11 +233,12 @@ load_section (void *section, struct execdata *u) u->error = (page == -1) ? errno : 0; if (! u->error) { - memcpy ((void *) page, /* XXX/fault */ + u->error = hurd_safe_copyin ((void *) page, /* XXX/fault */ (void *) (contents + (size - off)), off); - u->error = vm_write (u->task, mapstart + (size - off), - page, vm_page_size); + if (! u->error) + u->error = vm_write (u->task, mapstart + (size - off), + page, vm_page_size); munmap ((caddr_t) page, vm_page_size); } } @@ -339,7 +340,10 @@ load_section (void *section, struct execdata *u) const void *contents = map (u, filepos, readsize); if (!contents) goto maplose; - memcpy (readaddr, contents, readsize); /* XXX/fault */ + u->error = hurd_safe_copyin (readaddr, contents, + readsize); /* XXX/fault */ + if (u->error) + goto maplose; } u->error = vm_write (u->task, overlap_page, ourpage, size); if (u->error == KERN_PROTECTION_FAILURE) @@ -443,7 +447,9 @@ map (struct execdata *e, off_t posn, size_t len) else if (posn + len > size) /* The requested data wouldn't fit in the file. */ return NULL; - else if (e->filemap == MACH_PORT_NULL) + else if (e->file_data != NULL) { + return e->file_data + posn; + } else if (e->filemap == MACH_PORT_NULL) { /* No mapping for the file. Read the data by RPC. */ char *buffer = map_buffer (e); @@ -519,7 +525,10 @@ prepare_stream (struct execdata *e) e->map_filepos = 0; } -static void prepare_in_memory (struct execdata *e) {} +static void prepare_in_memory (struct execdata *e) +{ + prepare_stream(e); +} #else @@ -1008,10 +1017,13 @@ finish (struct execdata *e, int dealloc_file) #ifdef EXECDATA_STREAM fclose (&e->stream); #else - if (e->file_data != NULL) + if (e->file_data != NULL) { free (e->file_data); - else if (map_buffer (e) != NULL) + e->file_data = NULL; + } else if (map_buffer (e) != NULL) { munmap (map_buffer (e), map_vsize (e)); + map_buffer (e) = NULL; + } #endif } if (dealloc_file && e->file != MACH_PORT_NULL) @@ -1142,7 +1154,11 @@ check_gzip (struct execdata *earg) return -1; } n = MIN (maxread, map_buffer (e) + map_fsize (e) - contents); - memcpy (buf, contents, n); /* XXX/fault */ + errno = hurd_safe_copyin (buf, contents, n); /* XXX/fault */ + if (errno) + longjmp (ziperr, 2); + + zipread_pos += n; return n; } void zipwrite (const char *buf, size_t nwrite) @@ -1202,8 +1218,6 @@ check_gzip (struct execdata *earg) /* The output is complete. Clean up the stream and store its resultant buffer and size in the execdata as the file contents. */ fclose (zipout); - e->file_data = zipdata; - e->file_size = zipdatasz; /* Clean up the old exec file stream's state. Now that we have the contents all in memory (in E->file_data), @@ -1211,6 +1225,8 @@ check_gzip (struct execdata *earg) finish (e, 0); /* Prepare the stream state to use the file contents already in memory. */ + e->file_data = zipdata; + e->file_size = zipdatasz; prepare_in_memory (e); } #endif @@ -1248,7 +1264,11 @@ check_bzip2 (struct execdata *earg) return -1; } n = MIN (maxread, map_buffer (e) + map_fsize (e) - contents); - memcpy (buf, contents, n); /* XXX/fault */ + errno = hurd_safe_copyin (buf, contents, n); /* XXX/fault */ + if (errno) + longjmp (ziperr, 2); + + zipread_pos += n; return n; } void zipwrite (const char *buf, size_t nwrite) @@ -1297,8 +1317,6 @@ check_bzip2 (struct execdata *earg) /* The output is complete. Clean up the stream and store its resultant buffer and size in the execdata as the file contents. */ fclose (zipout); - e->file_data = zipdata; - e->file_size = zipdatasz; /* Clean up the old exec file stream's state. Now that we have the contents all in memory (in E->file_data), @@ -1306,6 +1324,8 @@ check_bzip2 (struct execdata *earg) finish (e, 0); /* Prepare the stream state to use the file contents already in memory. */ + e->file_data = zipdata; + e->file_size = zipdatasz; prepare_in_memory (e); } #endif @@ -1881,8 +1901,6 @@ do_exec (file_t file, proc_reassign (proc, newtask); mach_port_deallocate (mach_task_self (), proc); } - - mach_port_deallocate (mach_task_self (), oldtask); } /* Make sure the proc server has the right idea of our identity. */ diff --git a/exec/hashexec.c b/exec/hashexec.c index f880983d..2aa3844b 100644 --- a/exec/hashexec.c +++ b/exec/hashexec.c @@ -127,12 +127,16 @@ check_hashbang (struct execdata *e, name, flags, 0, result); } - const char *page = map (e, 0, 2); + const char *page; char interp_buf[vm_page_size - 2 + 1]; + e->error = 0; + page = map (e, 0, 2); + if (!page) { - e->error = errno; + if (!e->error) + e->error = ENOEXEC; return; } |