Deleted Added
sdiff udiff text old ( 220373 ) new ( 231885 )
full compact
1/*-
2 * ----------------------------------------------------------------------------
3 * "THE BEER-WARE LICENSE" (Revision 42):
4 * <phk@FreeBSD.org> wrote this file. As long as you retain this notice you
5 * can do whatever you want with this stuff. If we meet some day, and you think
6 * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
7 * ----------------------------------------------------------------------------
8 */

--- 8 unchanged lines hidden (view full) ---

17 * should handle the entire header of gzip'ed stuff.
18 * inflate isn't quite reentrant yet...
19 * error-handling is a mess...
20 * so is the rest...
21 * tidy up unnecesary includes
22 */
23
24#include <sys/cdefs.h>
25__FBSDID("$FreeBSD: head/sys/kern/imgact_gzip.c 231885 2012-02-17 23:47:16Z kib $");
26
27#include <sys/param.h>
28#include <sys/exec.h>
29#include <sys/imgact.h>
30#include <sys/imgact_aout.h>
31#include <sys/kernel.h>
32#include <sys/lock.h>
33#include <sys/mman.h>

--- 31 unchanged lines hidden (view full) ---

65static int NextByte(void *vp);
66static int do_aout_hdr(struct imgact_gzip *);
67static int Flush(void *vp, u_char *, u_long siz);
68
69static int
70exec_gzip_imgact(imgp)
71 struct image_params *imgp;
72{
73 int error;
74 const u_char *p = (const u_char *) imgp->image_header;
75 struct imgact_gzip igz;
76 struct inflate infl;
77 struct vmspace *vmspace;
78
79 /* If these four are not OK, it isn't a gzip file */
80 if (p[0] != 0x1f)
81 return -1; /* 0 Simply magic */

--- 49 unchanged lines hidden (view full) ---

131 vmspace = imgp->proc->p_vmspace;
132 error = vm_map_protect(&vmspace->vm_map,
133 (vm_offset_t) vmspace->vm_taddr,
134 (vm_offset_t) (vmspace->vm_taddr +
135 (vmspace->vm_tsize << PAGE_SHIFT)) ,
136 VM_PROT_READ|VM_PROT_EXECUTE,0);
137 }
138
139 if (igz.inbuf)
140 kmem_free_wakeup(exec_map, (vm_offset_t)igz.inbuf, PAGE_SIZE);
141 if (igz.error || error) {
142 printf("Output=%lu ", igz.output);
143 printf("Inflate_error=%d igz.error=%d where=%d\n",
144 error, igz.error, igz.where);
145 }
146 if (igz.error)
147 return igz.error;
148 if (error)
149 return ENOEXEC;
150 return 0;
151}
152
153static int
154do_aout_hdr(struct imgact_gzip * gz)
155{
156 int error;
157 struct vmspace *vmspace;

--- 146 unchanged lines hidden (view full) ---

304
305 if (igz->idx >= igz->len) {
306 igz->where = __LINE__;
307 return GZ_EOF;
308 }
309 if (igz->inbuf && igz->idx < (igz->offset + PAGE_SIZE)) {
310 return igz->inbuf[(igz->idx++) - igz->offset];
311 }
312 if (igz->inbuf)
313 kmem_free_wakeup(exec_map, (vm_offset_t)igz->inbuf, PAGE_SIZE);
314 igz->offset = igz->idx & ~PAGE_MASK;
315
316 error = vm_mmap(exec_map, /* map */
317 (vm_offset_t *) & igz->inbuf, /* address */
318 PAGE_SIZE, /* size */
319 VM_PROT_READ, /* protection */
320 VM_PROT_READ, /* max protection */
321 0, /* flags */
322 OBJT_VNODE, /* handle type */
323 igz->ip->vp, /* vnode */
324 igz->offset); /* offset */

--- 69 unchanged lines hidden ---