* [PATCH] erofs-utils: lib: return error on ZSTD decompression length mismatch
@ 2026-03-19 10:17 Utkal Singh
2026-03-19 10:18 ` Gao Xiang
2026-03-20 8:26 ` Nithurshen
0 siblings, 2 replies; 4+ messages in thread
From: Utkal Singh @ 2026-03-19 10:17 UTC (permalink / raw)
To: linux-erofs; +Cc: hsiangkao, Utkal Singh
When ZSTD_decompress() returns a size different from the expected
decoded size, the current code logs an error and jumps to cleanup
without setting ret to a negative value.
Since ret still holds a positive byte count, the caller interprets
it as success, potentially treating incorrectly decompressed data
as valid output.
Set ret to -EIO before jumping to cleanup, consistent with the
existing ZSTD_isError() handling above.
Signed-off-by: Utkal Singh <singhutkal015@gmail.com>
---
lib/decompress.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/lib/decompress.c b/lib/decompress.c
index 3e7a173..ef1271c 100644
--- a/lib/decompress.c
+++ b/lib/decompress.c
@@ -68,6 +68,7 @@ static int z_erofs_decompress_zstd(struct z_erofs_decompress_req *rq)
if (ret != (int)total) {
erofs_err("ZSTD decompress length mismatch %d, expected %d",
ret, total);
+ ret = -EIO;
goto out;
}
if (rq->decodedskip || total != rq->decodedlength)
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] erofs-utils: lib: return error on ZSTD decompression length mismatch
2026-03-19 10:17 [PATCH] erofs-utils: lib: return error on ZSTD decompression length mismatch Utkal Singh
@ 2026-03-19 10:18 ` Gao Xiang
2026-03-20 8:26 ` Nithurshen
1 sibling, 0 replies; 4+ messages in thread
From: Gao Xiang @ 2026-03-19 10:18 UTC (permalink / raw)
To: Utkal Singh, linux-erofs
On 2026/3/19 18:17, Utkal Singh wrote:
> When ZSTD_decompress() returns a size different from the expected
> decoded size, the current code logs an error and jumps to cleanup
> without setting ret to a negative value.
>
> Since ret still holds a positive byte count, the caller interprets
> it as success, potentially treating incorrectly decompressed data
> as valid output.
>
> Set ret to -EIO before jumping to cleanup, consistent with the
> existing ZSTD_isError() handling above.
>
> Signed-off-by: Utkal Singh <singhutkal015@gmail.com>
Please stop resending the patch without any modification.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] erofs-utils: lib: return error on ZSTD decompression length mismatch
2026-03-19 10:17 [PATCH] erofs-utils: lib: return error on ZSTD decompression length mismatch Utkal Singh
2026-03-19 10:18 ` Gao Xiang
@ 2026-03-20 8:26 ` Nithurshen
2026-03-20 9:29 ` Gao Xiang
1 sibling, 1 reply; 4+ messages in thread
From: Nithurshen @ 2026-03-20 8:26 UTC (permalink / raw)
To: singhutkal015; +Cc: hsiangkao, linux-erofs, Nithurshen
Hi Utkal,
This patch LGTM.
Reviewed-by: Nithurshen <nithurshen.dev@gmail.com>
Tested-by: Nithurshen <nithurshen.dev@gmail.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] erofs-utils: lib: return error on ZSTD decompression length mismatch
2026-03-20 8:26 ` Nithurshen
@ 2026-03-20 9:29 ` Gao Xiang
0 siblings, 0 replies; 4+ messages in thread
From: Gao Xiang @ 2026-03-20 9:29 UTC (permalink / raw)
To: Nithurshen, singhutkal015; +Cc: linux-erofs
On 2026/3/20 16:26, Nithurshen wrote:
> Hi Utkal,
>
> This patch LGTM.
>
> Reviewed-by: Nithurshen <nithurshen.dev@gmail.com>
> Tested-by: Nithurshen <nithurshen.dev@gmail.com>
I merge another patch of him instead, which assigns ret
as 0 on success.
Thanks,
Gao Xiang
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-03-20 9:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-19 10:17 [PATCH] erofs-utils: lib: return error on ZSTD decompression length mismatch Utkal Singh
2026-03-19 10:18 ` Gao Xiang
2026-03-20 8:26 ` Nithurshen
2026-03-20 9:29 ` Gao Xiang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox