erofs-utils: lib: return error on ZSTD decompression length mismatch
PATCH 1/1 erofs-utils: lib: return error on ZSTD decompression length mismatch
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.
--- lib/decompress.c | 1 + 1 file changed, 1 insertion(+)
lib/decompress.c +1 -0
@@ -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)
Signature · 1 line
2.43.0
Quoted 4 lines · 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.
Quoted 8 lines
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
-EIObefore jumping to cleanup, consistent with the existingZSTD_isError()handling above.Signed-off-by Utkal Singh <[email protected]>
Please stop resending the patch without any modification.
Hi Utkal,
This patch LGTM.
Quoted 6 lines · Nithurshen
Hi Utkal,
This patch LGTM.
Reviewed-by Nithurshen <[email protected]>Tested-by Nithurshen <[email protected]>
I merge another patch of him instead, which assigns ret as 0 on success.
Thanks,
Gao Xiang