summaryrefslogtreecommitdiffstats
path: root/sys/kern/imgact_gzip.c
diff options
context:
space:
mode:
authorhoek <hoek@FreeBSD.org>1999-06-21 16:23:13 +0000
committerhoek <hoek@FreeBSD.org>1999-06-21 16:23:13 +0000
commit580755b7c80e237d70b3d44e2c3cb94bb7b9d304 (patch)
tree8632ec1197441d68a0f84fcf0f1850a6795e2a29 /sys/kern/imgact_gzip.c
parenteba023799a120e4af79f68b707dd19fe36f7dee3 (diff)
downloadFreeBSD-src-580755b7c80e237d70b3d44e2c3cb94bb7b9d304.zip
FreeBSD-src-580755b7c80e237d70b3d44e2c3cb94bb7b9d304.tar.gz
Correctly return ENOEXEC for really short zipped files. The way this is
done is less-than cute, but this whole file is suffering from some amount of bitrot. Execution of zipped files should probably be implemented in a manner similar to that of #!/interpreted files. PR: kern/10780
Diffstat (limited to 'sys/kern/imgact_gzip.c')
-rw-r--r--sys/kern/imgact_gzip.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/sys/kern/imgact_gzip.c b/sys/kern/imgact_gzip.c
index 0c410f3..09e52f1 100644
--- a/sys/kern/imgact_gzip.c
+++ b/sys/kern/imgact_gzip.c
@@ -6,7 +6,7 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
- * $Id: imgact_gzip.c,v 1.36 1999/01/29 22:59:43 dillon Exp $
+ * $Id: imgact_gzip.c,v 1.37 1999/05/09 16:04:09 peter Exp $
*
* This module handles execution of a.out files which have been run through
* "gzip". This saves diskspace, but wastes cpu-cycles and VM.
@@ -47,6 +47,7 @@ struct imgact_gzip {
struct image_params *ip;
struct exec a_out;
int error;
+ int gotheader;
int where;
u_char *inbuf;
u_long offset;
@@ -115,6 +116,13 @@ exec_gzip_imgact(imgp)
error = inflate(&infl);
+ /*
+ * The unzipped file may not even have been long enough to contain
+ * a header giving Flush() a chance to return error. Check for this.
+ */
+ if ( !igz.gotheader )
+ return ENOEXEC;
+
if ( !error ) {
vmspace = imgp->proc->p_vmspace;
error = vm_map_protect(&vmspace->vm_map,
@@ -329,6 +337,7 @@ Flush(void *vp, u_char * ptr, u_long siz)
p += i;
siz -= i;
if (gz->output == sizeof gz->a_out) {
+ gz->gotheader = 1;
i = do_aout_hdr(gz);
if (i == -1) {
if (!gz->where)
OpenPOWER on IntegriCloud