U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: whr@rivoreo.one
To: u-boot@lists.denx.de
Cc: "Tom Rini" <trini@konsulko.com>, mwleeds@mailtundra.com
Subject: [PATCH] zfs: fix function 'zlib_decompress' pointlessly calling itself
Date: Tue, 30 Apr 2024 17:57:45 +0800	[thread overview]
Message-ID: <682d8b79cb2c1ef72eebf9a25329e938.squirrel@_> (raw)

[-- Attachment #1: Type: text/plain, Size: 178 bytes --]

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

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

[-- Attachment #2: 0001-zfs-fix-function-zlib_decompress-pointlessly-calling --]
[-- Type: /, Size: 565 bytes --]

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;
 }

             reply	other threads:[~2024-04-30 12:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-30  9:57 whr [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-04-30 16:40 [PATCH] zfs: fix function 'zlib_decompress' pointlessly calling itself WHR
2024-05-14 16:15 ` Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=682d8b79cb2c1ef72eebf9a25329e938.squirrel@_ \
    --to=whr@rivoreo.one \
    --cc=mwleeds@mailtundra.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox