Skip to contentSkip to conversation

zfs: fix function 'zlib_decompress' pointlessly calling itself

PATCH In review WHR 2 participants 2 messages Apr 30, 2024 – May 14, 2024

lore
Share & tools
lore

WHR

author
#0 lore raw

PATCH 1/1 zfs: fix function 'zlib_decompress' pointlessly calling itself

In order to prevent crashing due to infinite recursion and actually decompress the requested data, call the zlib function 'uncompress' instead.

---
v2:
Resubmit with diff content in plain text.

fs/zfs/zfs.c +3 -1
index bfc11fa667..4896cc18ef 100644
@@ -17,6 +17,7 @@
 #include <linux/time.h>
 #include <linux/ctype.h>
 #include <asm/byteorder.h>
+#include <u-boot/zlib.h>
 #include "zfs_common.h"
 #include "div64.h"
 
@@ -183,7 +184,8 @@ static int
 zlib_decompress(void *s, void *d,
 				uint32_t slen, uint32_t dlen)
 {
-	if (zlib_decompress(s, d, slen, dlen) < 0)
+	uLongf z_dest_len = dlen;
+	if (uncompress(d, &z_dest_len, s, slen) != Z_OK)
 		return ZFS_ERR_BAD_FS;
 	return ZFS_ERR_NONE;
 }
#1 lore raw
Quoted 5 lines · WHR

In order to prevent crashing due to infinite recursion and actually decompress the requested data, call the zlib function 'uncompress' instead.

Applied to u-boot/next, thanks!

Signature · 1 line
Tom