Ahem. Don't invert the length _twice_.
[sgt/halibut] / deflate.c
index ecae0d0..5bb3cce 100644 (file)
--- a/deflate.c
+++ b/deflate.c
@@ -2443,6 +2443,10 @@ int deflate_decompress_data(deflate_decompress_ctx *dctx,
                goto finished;
            nlen = dctx->bits & 0xFFFF;
            EATBITS(16);
+           if (dctx->uncomplen != (nlen ^ 0xFFFF)) {
+                error = DEFLATE_ERR_UNCOMP_HDR;
+                goto finished;
+            }
            if (dctx->uncomplen == 0)
                dctx->state = OUTSIDEBLK;       /* block is empty */
            else