patch-2.3.40 linux/fs/cramfs/uncompress.c

Next file: linux/fs/ext2/file.c
Previous file: linux/fs/cramfs/inode.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.39/linux/fs/cramfs/uncompress.c linux/fs/cramfs/uncompress.c
@@ -22,6 +22,7 @@
 static z_stream stream;
 static int initialized = 0;
 
+/* Returns length of decompressed data. */
 int cramfs_uncompress_block(void *dst, int dstlen, void *src, int srclen)
 {
 	int err;
@@ -32,14 +33,22 @@
 	stream.next_out = dst;
 	stream.avail_out = dstlen;
 
-	inflateReset(&stream);
+	err = inflateReset(&stream);
+	if (err != Z_OK) {
+		printk("inflateReset error %d\n", err);
+		inflateEnd(&stream);
+		inflateInit(&stream);
+	}
 
 	err = inflate(&stream, Z_FINISH);
-	if (err != Z_STREAM_END) {
-		printk("Error %d while decompressing!\n", err);
-		printk("%p(%d)->%p(%d)\n", src, srclen, dst, dstlen);
-	}
+	if (err != Z_STREAM_END)
+		goto err;
 	return stream.total_out;
+
+err:
+	printk("Error %d while decompressing!\n", err);
+	printk("%p(%d)->%p(%d)\n", src, srclen, dst, dstlen);
+	return 0;
 }
 
 int cramfs_uncompress_init(void)

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)