[gmime/gmime-2-4] Properly handle Z_BUF_ERRORs in the gzip filter



commit 2aa3728b1b942c6dd09b589ca12b686c9f927de9
Author: Jeffrey Stedfast <fejj gnome org>
Date:   Mon Oct 22 01:36:20 2012 -0400

    Properly handle Z_BUF_ERRORs in the gzip filter
    
    2012-10-20  Jeffrey Stedfast  <fejj gnome org>
    
    	* gmime/gmime-filter-gzip.c (gunzip_filter): Apparently
    	Z_BUF_ERROR isn't actually an error unless there is input
    	available. Thanks to Pavlo <devgs ukr net> for this patch.

 ChangeLog                 |    6 ++++++
 gmime/gmime-filter-gzip.c |   14 +++++++++++---
 2 files changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 812d9a8..7a8cc19 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2012-10-20  Jeffrey Stedfast  <fejj gnome org>
+
+	* gmime/gmime-filter-gzip.c (gunzip_filter): Apparently
+	Z_BUF_ERROR isn't actually an error unless there is input
+	available. Thanks to Pavlo <devgs ukr net> for this patch.
+
 2012-08-13  Jeffrey Stedfast  <jeff xamarin com>
 
 	* gmime/gmime-utils.c (tokenize_rfc2047_phrase): Don't forget to
diff --git a/gmime/gmime-filter-gzip.c b/gmime/gmime-filter-gzip.c
index 6d8d075..ac10879 100644
--- a/gmime/gmime-filter-gzip.c
+++ b/gmime/gmime-filter-gzip.c
@@ -30,6 +30,12 @@
 
 #include "gmime-filter-gzip.h"
 
+#ifdef ENABLE_WARNINGS
+#define w(x) x
+#else
+#define w(x)
+#endif /* ENABLE_WARNINGS */
+
 
 /**
  * SECTION: gmime-filter-gzip
@@ -231,7 +237,7 @@ gzip_filter (GMimeFilter *filter, char *in, size_t len, size_t prespace,
 	do {
 		/* FIXME: handle error cases? */
 		if ((retval = deflate (priv->stream, flush)) != Z_OK)
-			fprintf (stderr, "gzip: %d: %s\n", retval, priv->stream->msg);
+			w(fprintf (stderr, "gzip: %d: %s\n", retval, priv->stream->msg));
 		
 		if (flush == Z_FULL_FLUSH) {
 			size_t outlen;
@@ -384,8 +390,10 @@ gunzip_filter (GMimeFilter *filter, char *in, size_t len, size_t prespace,
 	
 	do {
 		/* FIXME: handle error cases? */
-		if ((retval = inflate (priv->stream, flush)) != Z_OK)
-			fprintf (stderr, "gunzip: %d: %s\n", retval, priv->stream->msg);
+		/* Note: Z_BUF_ERROR is not really an error unless there is input available */
+		if ((retval = inflate (priv->stream, flush)) != Z_OK &&
+		    !(retval == Z_BUF_ERROR && !priv->stream->avail_in))
+			w(fprintf (stderr, "gunzip: %d: %s\n", retval, priv->stream->msg));
 		
 		if (flush == Z_FULL_FLUSH) {
 			size_t outlen;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]