mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 08:25:20 +09:00
compress: deal with zstd decoder issues gracefully
If zstd frames are corrupted the initial size returned for the current frame might be wrong. Don#t assert() on that, but handle it gracefully, as EBADMSG
This commit is contained in:
@@ -495,11 +495,10 @@ int decompress_blob_zstd(
|
||||
};
|
||||
|
||||
size_t k = sym_ZSTD_decompressStream(dctx, &output, &input);
|
||||
if (sym_ZSTD_isError(k)) {
|
||||
log_debug("ZSTD decoder failed: %s", sym_ZSTD_getErrorName(k));
|
||||
return zstd_ret_to_errno(k);
|
||||
}
|
||||
assert(output.pos >= size);
|
||||
if (sym_ZSTD_isError(k))
|
||||
return log_debug_errno(zstd_ret_to_errno(k), "ZSTD decoder failed: %s", sym_ZSTD_getErrorName(k));
|
||||
if (output.pos < size)
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(EBADMSG), "ZSTD decoded less data than indicated, probably corrupted stream.");
|
||||
|
||||
*dst_size = size;
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user