[PATCH] erofs-utils: lib: fix missing -EIO in z_erofs_decompress_zstd
Utkal Singh
singhutkal015 at gmail.com
Sun Mar 15 09:07:13 AEDT 2026
When ZSTD_decompress() produces fewer bytes than expected, the
error path logged an error and did 'goto out' without setting
ret to -EIO. The caller in data.c checks (ret < 0), so a
positive ret was silently treated as success, potentially
consuming corrupted data without any error being propagated.
Set ret = -EIO before the jump, and add an explicit ret = 0
on the success path for symmetry with other decompressors.
Fixes: ed2f7cf ("erofs-utils: add preliminary zstd support [x]")
Signed-off-by: Utkal Singh <singhutkal015 at gmail.com>
---
lib/decompress.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/lib/decompress.c b/lib/decompress.c
index 3e7a173..01f5e24 100644
--- a/lib/decompress.c
+++ b/lib/decompress.c
@@ -68,11 +68,13 @@ 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)
memcpy(rq->out, dest + rq->decodedskip,
rq->decodedlength - rq->decodedskip);
+ ret = 0;
out:
if (buff)
free(buff);
--
2.43.0
More information about the Linux-erofs
mailing list