Skip to contentSkip to conversation

Fix ppp_deflate issues with recent zlib_inflate changes

PATCH In review Richard Purdie 2 participants 2 messages May 3, 2007 – May 4, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix ppp_deflate issues with recent zlib_inflate changes

The last zlib_inflate update broke certain corner cases for ppp_deflate decompression handling. This patch fixes some logic to make things work properly again. Users other than ppp_deflate (the only Z_PACKET_FLUSH user) should be unaffected.

Fixes bug 8405 (confirmed by the reporter).

lib/zlib_inflate/inflate.c +5 -3
Index: linux/lib/zlib_inflate/inflate.c
===================================================================
@@ -743,12 +743,14 @@ int zlib_inflate(z_streamp strm, int flu
 
     strm->data_type = state->bits + (state->last ? 64 : 0) +
                       (state->mode == TYPE ? 128 : 0);
-    if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)
-        ret = Z_BUF_ERROR;
 
     if (flush == Z_PACKET_FLUSH && ret == Z_OK &&
-            (strm->avail_out != 0 || strm->avail_in == 0))
+            strm->avail_out != 0 && strm->avail_in == 0)
 		return zlib_inflateSyncPacket(strm);
+
+    if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)
+        ret = Z_BUF_ERROR;
+
     return ret;
 }
 
#1 lore raw
Quoted 21 lines · On Thu, 03 May 2007 23:18:09 +0100 Richard Purdie <[email protected]> wrote:

The last zlib_inflate update broke certain corner cases for ppp_deflate decompression handling. This patch fixes some logic to make things work properly again. Users other than ppp_deflate (the only Z_PACKET_FLUSH user) should be unaffected.

Fixes bug 8405 (confirmed by the reporter).

Index: linux/lib/zlib_inflate/inflate.c
===================================================================

lib/zlib_inflate/inflate.c +0 -2
@@ -743,12 +743,14 @@ int zlib_inflate(z_streamp strm, int flu
 
     strm->data_type = state->bits + (state->last ? 64 : 0) +
                       (state->mode == TYPE ? 128 : 0);
-    if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)
-        ret = Z_BUF_ERROR;
 
     if (flush == Z_PACKET_FLUSH && ret == Z_OK &&

lib/zlib_inflate/inflate.c int zlib_inflate(z_streamp strm, int flu · line 756

Quoted 10 lines
lib/zlib_inflate/inflate.c +5 -1
-            (strm->avail_out != 0 || strm->avail_in == 0))
+            strm->avail_out != 0 && strm->avail_in == 0)
 		return zlib_inflateSyncPacket(strm);
+
+    if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)
+        ret = Z_BUF_ERROR;
+
     return ret;
 }
 

Thanks heaps, guys. It was a tough one. I'll tag it for 2.6.21.x too.