diff options
Diffstat (limited to 'lib/decompress_inflate.c')
-rw-r--r-- | lib/decompress_inflate.c | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/lib/decompress_inflate.c b/lib/decompress_inflate.c index d4c7891635ec..555c06bf20da 100644 --- a/lib/decompress_inflate.c +++ b/lib/decompress_inflate.c | |||
@@ -1,4 +1,5 @@ | |||
1 | #ifdef STATIC | 1 | #ifdef STATIC |
2 | #define PREBOOT | ||
2 | /* Pre-boot environment: included */ | 3 | /* Pre-boot environment: included */ |
3 | 4 | ||
4 | /* prevent inclusion of _LINUX_KERNEL_H in pre-boot environment: lots | 5 | /* prevent inclusion of _LINUX_KERNEL_H in pre-boot environment: lots |
@@ -33,23 +34,23 @@ static long INIT nofill(void *buffer, unsigned long len) | |||
33 | } | 34 | } |
34 | 35 | ||
35 | /* Included from initramfs et al code */ | 36 | /* Included from initramfs et al code */ |
36 | STATIC int INIT gunzip(unsigned char *buf, long len, | 37 | STATIC int INIT __gunzip(unsigned char *buf, long len, |
37 | long (*fill)(void*, unsigned long), | 38 | long (*fill)(void*, unsigned long), |
38 | long (*flush)(void*, unsigned long), | 39 | long (*flush)(void*, unsigned long), |
39 | unsigned char *out_buf, | 40 | unsigned char *out_buf, long out_len, |
40 | long *pos, | 41 | long *pos, |
41 | void(*error)(char *x)) { | 42 | void(*error)(char *x)) { |
42 | u8 *zbuf; | 43 | u8 *zbuf; |
43 | struct z_stream_s *strm; | 44 | struct z_stream_s *strm; |
44 | int rc; | 45 | int rc; |
45 | size_t out_len; | ||
46 | 46 | ||
47 | rc = -1; | 47 | rc = -1; |
48 | if (flush) { | 48 | if (flush) { |
49 | out_len = 0x8000; /* 32 K */ | 49 | out_len = 0x8000; /* 32 K */ |
50 | out_buf = malloc(out_len); | 50 | out_buf = malloc(out_len); |
51 | } else { | 51 | } else { |
52 | out_len = ((size_t)~0) - (size_t)out_buf; /* no limit */ | 52 | if (!out_len) |
53 | out_len = ((size_t)~0) - (size_t)out_buf; /* no limit */ | ||
53 | } | 54 | } |
54 | if (!out_buf) { | 55 | if (!out_buf) { |
55 | error("Out of memory while allocating output buffer"); | 56 | error("Out of memory while allocating output buffer"); |
@@ -181,4 +182,24 @@ gunzip_nomem1: | |||
181 | return rc; /* returns Z_OK (0) if successful */ | 182 | return rc; /* returns Z_OK (0) if successful */ |
182 | } | 183 | } |
183 | 184 | ||
184 | #define decompress gunzip | 185 | #ifndef PREBOOT |
186 | STATIC int INIT gunzip(unsigned char *buf, long len, | ||
187 | long (*fill)(void*, unsigned long), | ||
188 | long (*flush)(void*, unsigned long), | ||
189 | unsigned char *out_buf, | ||
190 | long *pos, | ||
191 | void (*error)(char *x)) | ||
192 | { | ||
193 | return __gunzip(buf, len, fill, flush, out_buf, 0, pos, error); | ||
194 | } | ||
195 | #else | ||
196 | STATIC int INIT __decompress(unsigned char *buf, long len, | ||
197 | long (*fill)(void*, unsigned long), | ||
198 | long (*flush)(void*, unsigned long), | ||
199 | unsigned char *out_buf, long out_len, | ||
200 | long *pos, | ||
201 | void (*error)(char *x)) | ||
202 | { | ||
203 | return __gunzip(buf, len, fill, flush, out_buf, out_len, pos, error); | ||
204 | } | ||
205 | #endif | ||