Deleted Added
full compact
imgact_gzip.c (15494) imgact_gzip.c (15538)
1/*
2 * ----------------------------------------------------------------------------
3 * "THE BEER-WARE LICENSE" (Revision 42):
4 * <phk@login.dkuug.dk> 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 *
1/*
2 * ----------------------------------------------------------------------------
3 * "THE BEER-WARE LICENSE" (Revision 42):
4 * <phk@login.dkuug.dk> 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 *
9 * $Id: imgact_gzip.c,v 1.20 1996/03/19 15:02:47 bde Exp $
9 * $Id: imgact_gzip.c,v 1.21 1996/05/01 02:42:50 bde Exp $
10 *
11 * This module handles execution of a.out files which have been run through
12 * "gzip". This saves diskspace, but wastes cpu-cycles and VM.
13 *
14 * TODO:
15 * text-segments should be made R/O after being filled
16 * is the vm-stuff safe ?
17 * should handle the entire header of gzip'ed stuff.

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

143 /*
144 * Set file/virtual offset based on a.out variant. We do two cases:
145 * host byte order and network byte order (for NetBSD compatibility)
146 */
147 switch ((int) (gz->a_out.a_magic & 0xffff)) {
148 case ZMAGIC:
149 gz->virtual_offset = 0;
150 if (gz->a_out.a_text) {
10 *
11 * This module handles execution of a.out files which have been run through
12 * "gzip". This saves diskspace, but wastes cpu-cycles and VM.
13 *
14 * TODO:
15 * text-segments should be made R/O after being filled
16 * is the vm-stuff safe ?
17 * should handle the entire header of gzip'ed stuff.

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

143 /*
144 * Set file/virtual offset based on a.out variant. We do two cases:
145 * host byte order and network byte order (for NetBSD compatibility)
146 */
147 switch ((int) (gz->a_out.a_magic & 0xffff)) {
148 case ZMAGIC:
149 gz->virtual_offset = 0;
150 if (gz->a_out.a_text) {
151 gz->file_offset = NBPG;
151 gz->file_offset = PAGE_SIZE;
152 } else {
153 /* Bill's "screwball mode" */
154 gz->file_offset = 0;
155 }
156 break;
157 case QMAGIC:
152 } else {
153 /* Bill's "screwball mode" */
154 gz->file_offset = 0;
155 }
156 break;
157 case QMAGIC:
158 gz->virtual_offset = NBPG;
158 gz->virtual_offset = PAGE_SIZE;
159 gz->file_offset = 0;
160 break;
161 default:
162 /* NetBSD compatibility */
163 switch ((int) (ntohl(gz->a_out.a_magic) & 0xffff)) {
164 case ZMAGIC:
165 case QMAGIC:
159 gz->file_offset = 0;
160 break;
161 default:
162 /* NetBSD compatibility */
163 switch ((int) (ntohl(gz->a_out.a_magic) & 0xffff)) {
164 case ZMAGIC:
165 case QMAGIC:
166 gz->virtual_offset = NBPG;
166 gz->virtual_offset = PAGE_SIZE;
167 gz->file_offset = 0;
168 break;
169 default:
170 gz->where = __LINE__;
171 return (-1);
172 }
173 }
174
167 gz->file_offset = 0;
168 break;
169 default:
170 gz->where = __LINE__;
171 return (-1);
172 }
173 }
174
175 gz->bss_size = roundup(gz->a_out.a_bss, NBPG);
175 gz->bss_size = roundup(gz->a_out.a_bss, PAGE_SIZE);
176
177 /*
178 * Check various fields in header for validity/bounds.
179 */
180 if ( /* entry point must lay with text region */
181 gz->a_out.a_entry < gz->virtual_offset ||
182 gz->a_out.a_entry >= gz->virtual_offset + gz->a_out.a_text ||
183
184 /* text and data size must each be page rounded */
176
177 /*
178 * Check various fields in header for validity/bounds.
179 */
180 if ( /* entry point must lay with text region */
181 gz->a_out.a_entry < gz->virtual_offset ||
182 gz->a_out.a_entry >= gz->virtual_offset + gz->a_out.a_text ||
183
184 /* text and data size must each be page rounded */
185 gz->a_out.a_text % NBPG ||
186 gz->a_out.a_data % NBPG) {
185 gz->a_out.a_text & PAGE_MASK || gz->a_out.a_data & PAGE_MASK) {
187 gz->where = __LINE__;
188 return (-1);
189 }
190 /*
191 * text/data/bss must not exceed limits
192 */
193 if ( /* text can't exceed maximum text size */
194 gz->a_out.a_text > MAXTSIZ ||

--- 189 unchanged lines hidden ---
186 gz->where = __LINE__;
187 return (-1);
188 }
189 /*
190 * text/data/bss must not exceed limits
191 */
192 if ( /* text can't exceed maximum text size */
193 gz->a_out.a_text > MAXTSIZ ||

--- 189 unchanged lines hidden ---