Commit f039ada5c10925147eb5bb15f63c430dbde76c3f

Authored by Catalin Radu
Committed by Wolfgang Denk
1 parent 1472af34c1

Fix gunzip to work for any gziped uImage size

Signed-off-by: Catalin Radu <Catalin@VirtualMetrix.com>

Showing 1 changed file with 10 additions and 6 deletions Side-by-side Diff

... ... @@ -106,12 +106,16 @@
106 106 s.avail_in = *lenp - offset;
107 107 s.next_out = dst;
108 108 s.avail_out = dstlen;
109   - r = inflate(&s, Z_FINISH);
110   - if ((r != Z_STREAM_END) && (stoponerr==1)) {
111   - printf ("Error: inflate() returned %d\n", r);
112   - inflateEnd(&s);
113   - return (-1);
114   - }
  109 + do {
  110 + r = inflate(&s, Z_FINISH);
  111 + if (r != Z_STREAM_END && r != Z_BUF_ERROR && stoponerr == 1) {
  112 + printf("Error: inflate() returned %d\n", r);
  113 + inflateEnd(&s);
  114 + return -1;
  115 + }
  116 + s.avail_in = *lenp - offset - (int)(s.next_out - (unsigned char*)dst);
  117 + s.avail_out = dstlen;
  118 + } while (r == Z_BUF_ERROR);
115 119 *lenp = s.next_out - (unsigned char *) dst;
116 120 inflateEnd(&s);
117 121