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
This commit is contained in:
Tim Vanderhoek 1999-06-21 16:23:13 +00:00
parent 35cd460f8a
commit 8630d8cfc6
1 changed files with 10 additions and 1 deletions

View File

@ -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)