public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] Fix gunzip to work for any gziped uImage size
@ 2011-02-04 12:35 Catalin Radu
  2011-02-05  9:42 ` Albert ARIBAUD
  2011-04-12 19:05 ` Wolfgang Denk
  0 siblings, 2 replies; 6+ messages in thread
From: Catalin Radu @ 2011-02-04 12:35 UTC (permalink / raw)
  To: u-boot


Signed-off-by: Catalin Radu <Catalin@VirtualMetrix.com>
---
 lib/gunzip.c |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/lib/gunzip.c b/lib/gunzip.c
index 482a476..8b16b24 100644
--- a/lib/gunzip.c
+++ b/lib/gunzip.c
@@ -106,12 +106,16 @@ int zunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp,
 	s.avail_in = *lenp - offset;
 	s.next_out = dst;
 	s.avail_out = dstlen;
-	r = inflate(&s, Z_FINISH);
-	if ((r != Z_STREAM_END) && (stoponerr==1)) {
-		printf ("Error: inflate() returned %d\n", r);
-		inflateEnd(&s);
-		return (-1);
-	}
+	do {
+		r = inflate(&s, Z_FINISH);
+		if (r != Z_STREAM_END && r != Z_BUF_ERROR && stoponerr == 1) {
+			printf("Error: inflate() returned %d\n", r);
+			inflateEnd(&s);
+			return -1;
+		}
+		s.avail_in = *lenp - offset - (int)(s.next_out - (unsigned char*)dst);
+		s.avail_out = dstlen;
+	} while (r == Z_BUF_ERROR);
 	*lenp = s.next_out - (unsigned char *) dst;
 	inflateEnd(&s);
 
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] 6+ messages in thread
* [U-Boot] [PATCH] Fix gunzip to work for any gziped uImage size
@ 2011-02-03 13:32 Catalin Radu
  2011-02-04  5:23 ` Anthony Foiani
  0 siblings, 1 reply; 6+ messages in thread
From: Catalin Radu @ 2011-02-03 13:32 UTC (permalink / raw)
  To: u-boot


Signed-off-by: Catalin Radu <Catalin@VirtualMetrix.com>
---
 lib/gunzip.c |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/lib/gunzip.c b/lib/gunzip.c
index 482a476..2922608 100644
--- a/lib/gunzip.c
+++ b/lib/gunzip.c
@@ -106,12 +106,16 @@ int zunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp,
 	s.avail_in = *lenp - offset;
 	s.next_out = dst;
 	s.avail_out = dstlen;
-	r = inflate(&s, Z_FINISH);
-	if ((r != Z_STREAM_END) && (stoponerr==1)) {
-		printf ("Error: inflate() returned %d\n", r);
-		inflateEnd(&s);
-		return (-1);
-	}
+	do {
+		r = inflate(&s, Z_FINISH);
+		if ((r != Z_STREAM_END)&&  (r != Z_BUF_ERROR)&&  (stoponerr==1)) {
+			printf ("Error: inflate() returned %d\n", r);
+			inflateEnd(&s);
+	   		return (-1);
+	   	}
+		s.avail_in = *lenp - offset - (int)(s.next_out - (unsigned char*)dst);
+		s.avail_out = dstlen;
+	} while (r == Z_BUF_ERROR);
 	*lenp = s.next_out - (unsigned char *) dst;
 	inflateEnd(&s);
 
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-04-12 19:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-04 12:35 [U-Boot] [PATCH] Fix gunzip to work for any gziped uImage size Catalin Radu
2011-02-05  9:42 ` Albert ARIBAUD
2011-04-12 19:05 ` Wolfgang Denk
  -- strict thread matches above, loose matches on Subject: below --
2011-02-03 13:32 Catalin Radu
2011-02-04  5:23 ` Anthony Foiani
2011-02-04 11:41   ` Catalin Radu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox