diff options
Diffstat (limited to 'arch/powerpc/boot/gunzip_util.c')
-rw-r--r-- | arch/powerpc/boot/gunzip_util.c | 36 |
1 files changed, 12 insertions, 24 deletions
diff --git a/arch/powerpc/boot/gunzip_util.c b/arch/powerpc/boot/gunzip_util.c index f7c95f24fcdd..8a97adfac659 100644 --- a/arch/powerpc/boot/gunzip_util.c +++ b/arch/powerpc/boot/gunzip_util.c | |||
@@ -52,18 +52,14 @@ void gunzip_start(struct gunzip_state *state, void *src, int srclen) | |||
52 | int r, flags; | 52 | int r, flags; |
53 | 53 | ||
54 | state->s.workspace = state->scratch; | 54 | state->s.workspace = state->scratch; |
55 | if (zlib_inflate_workspacesize() > sizeof(state->scratch)) { | 55 | if (zlib_inflate_workspacesize() > sizeof(state->scratch)) |
56 | printf("insufficient scratch space for gunzip\n\r"); | 56 | fatal("insufficient scratch space for gunzip\n\r"); |
57 | exit(); | ||
58 | } | ||
59 | 57 | ||
60 | /* skip header */ | 58 | /* skip header */ |
61 | hdrlen = 10; | 59 | hdrlen = 10; |
62 | flags = hdr[3]; | 60 | flags = hdr[3]; |
63 | if (hdr[2] != Z_DEFLATED || (flags & RESERVED) != 0) { | 61 | if (hdr[2] != Z_DEFLATED || (flags & RESERVED) != 0) |
64 | printf("bad gzipped data\n\r"); | 62 | fatal("bad gzipped data\n\r"); |
65 | exit(); | ||
66 | } | ||
67 | if ((flags & EXTRA_FIELD) != 0) | 63 | if ((flags & EXTRA_FIELD) != 0) |
68 | hdrlen = 12 + hdr[10] + (hdr[11] << 8); | 64 | hdrlen = 12 + hdr[10] + (hdr[11] << 8); |
69 | if ((flags & ORIG_NAME) != 0) | 65 | if ((flags & ORIG_NAME) != 0) |
@@ -74,16 +70,12 @@ void gunzip_start(struct gunzip_state *state, void *src, int srclen) | |||
74 | ; | 70 | ; |
75 | if ((flags & HEAD_CRC) != 0) | 71 | if ((flags & HEAD_CRC) != 0) |
76 | hdrlen += 2; | 72 | hdrlen += 2; |
77 | if (hdrlen >= srclen) { | 73 | if (hdrlen >= srclen) |
78 | printf("gunzip_start: ran out of data in header\n\r"); | 74 | fatal("gunzip_start: ran out of data in header\n\r"); |
79 | exit(); | ||
80 | } | ||
81 | 75 | ||
82 | r = zlib_inflateInit2(&state->s, -MAX_WBITS); | 76 | r = zlib_inflateInit2(&state->s, -MAX_WBITS); |
83 | if (r != Z_OK) { | 77 | if (r != Z_OK) |
84 | printf("inflateInit2 returned %d\n\r", r); | 78 | fatal("inflateInit2 returned %d\n\r", r); |
85 | exit(); | ||
86 | } | ||
87 | } | 79 | } |
88 | 80 | ||
89 | state->s.next_in = src + hdrlen; | 81 | state->s.next_in = src + hdrlen; |
@@ -117,10 +109,8 @@ int gunzip_partial(struct gunzip_state *state, void *dst, int dstlen) | |||
117 | state->s.next_out = dst; | 109 | state->s.next_out = dst; |
118 | state->s.avail_out = dstlen; | 110 | state->s.avail_out = dstlen; |
119 | r = zlib_inflate(&state->s, Z_FULL_FLUSH); | 111 | r = zlib_inflate(&state->s, Z_FULL_FLUSH); |
120 | if (r != Z_OK && r != Z_STREAM_END) { | 112 | if (r != Z_OK && r != Z_STREAM_END) |
121 | printf("inflate returned %d msg: %s\n\r", r, state->s.msg); | 113 | fatal("inflate returned %d msg: %s\n\r", r, state->s.msg); |
122 | exit(); | ||
123 | } | ||
124 | len = state->s.next_out - (unsigned char *)dst; | 114 | len = state->s.next_out - (unsigned char *)dst; |
125 | } else { | 115 | } else { |
126 | /* uncompressed image */ | 116 | /* uncompressed image */ |
@@ -151,10 +141,8 @@ void gunzip_exactly(struct gunzip_state *state, void *dst, int dstlen) | |||
151 | int len; | 141 | int len; |
152 | 142 | ||
153 | len = gunzip_partial(state, dst, dstlen); | 143 | len = gunzip_partial(state, dst, dstlen); |
154 | if (len < dstlen) { | 144 | if (len < dstlen) |
155 | printf("gunzip_block: ran out of data\n\r"); | 145 | fatal("gunzip_block: ran out of data\n\r"); |
156 | exit(); | ||
157 | } | ||
158 | } | 146 | } |
159 | 147 | ||
160 | /** | 148 | /** |