public inbox for linux-erofs@ozlabs.org
 help / color / mirror / Atom feed
* [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

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