diff mbox series

zfs: fix function 'zlib_decompress' pointlessly calling itself

Message ID f1c277becf620ba6fd949758704076ce.squirrel@_
State Accepted
Commit 1466e065a94b3cd242f945f16c916a7f7da02985
Delegated to: Tom Rini
Headers show
Series zfs: fix function 'zlib_decompress' pointlessly calling itself | expand

Commit Message

WHR April 30, 2024, 4:40 p.m. UTC
In order to prevent crashing due to infinite recursion and actually
decompress the requested data, call the zlib function 'uncompress'
instead.

Signed-off-by: WHR <msl0000023508@gmail.com>

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

Comments

Tom Rini May 14, 2024, 4:15 p.m. UTC | #1
On Wed, May 01, 2024 at 12:40:38AM +0800, WHR wrote:

> In order to prevent crashing due to infinite recursion and actually
> decompress the requested data, call the zlib function 'uncompress'
> instead.
> 
> Signed-off-by: WHR <msl0000023508@gmail.com>

Applied to u-boot/next, thanks!
diff mbox series

Patch

diff --git a/fs/zfs/zfs.c b/fs/zfs/zfs.c
index bfc11fa667..4896cc18ef 100644
--- a/fs/zfs/zfs.c
+++ b/fs/zfs/zfs.c
@@ -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;
 }