Squashfs: add missing check in zlib_wrapper
Phillip Lougher [Wed, 5 Jan 2011 18:02:37 +0000 (18:02 +0000)]
On file system corruption zlib can return Z_STREAM_OK with
input buffers remaining, which will not be released.

Signed-off-by: Phillip Lougher <phillip@lougher.demon.co.uk>

fs/squashfs/zlib_wrapper.c

index 1f4833b..ab5801f 100644 (file)
@@ -127,6 +127,11 @@ static int zlib_uncompress(struct squashfs_sb_info *msblk, void **buffer,
                goto release_mutex;
        }
 
+       if (k < b) {
+               ERROR("zlib_uncompress error, data remaining\n");
+               goto release_mutex;
+       }
+
        length = stream->total_out;
        mutex_unlock(&msblk->read_data_mutex);
        return length;