Add checksum verification of metadata chunks.
This commit is contained in:
parent
d63f848a24
commit
5a742b94f0
1 changed files with 13 additions and 0 deletions
|
@ -327,6 +327,7 @@ decompress_data(meta_ctx_t *mctx)
|
||||||
/*
|
/*
|
||||||
* Verify Header CRC32 in non-crypto mode.
|
* Verify Header CRC32 in non-crypto mode.
|
||||||
*/
|
*/
|
||||||
|
deserialize_checksum(checksum, cbuf + 25, pctx->cksum_bytes);
|
||||||
crc1 = U32_P(cbuf + 25 + CKSUM_MAX);
|
crc1 = U32_P(cbuf + 25 + CKSUM_MAX);
|
||||||
memset(cbuf + 25 + CKSUM_MAX, 0, CRC32_SIZE);
|
memset(cbuf + 25 + CKSUM_MAX, 0, CRC32_SIZE);
|
||||||
crc2 = lzma_crc32(cbuf, METADATA_HDR_SZ, 0);
|
crc2 = lzma_crc32(cbuf, METADATA_HDR_SZ, 0);
|
||||||
|
@ -361,6 +362,18 @@ decompress_data(meta_ctx_t *mctx)
|
||||||
}
|
}
|
||||||
memcpy(ubuf, cseg, dstlen);
|
memcpy(ubuf, cseg, dstlen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Now verify normal checksum if not using encryption.
|
||||||
|
*/
|
||||||
|
if (!pctx->encrypt_type) {
|
||||||
|
compute_checksum(mctx->checksum, pctx->cksum, ubuf, dstlen, 0, 1);
|
||||||
|
if (memcmp(checksum, mctx->checksum, pctx->cksum_bytes) != 0) {
|
||||||
|
log_msg(LOG_ERR, 0, "Metadata chunk %d, Checksum verification failed",
|
||||||
|
mctx->id);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
}
|
||||||
mctx->topos = 0;
|
mctx->topos = 0;
|
||||||
mctx->tosize = dstlen;
|
mctx->tosize = dstlen;
|
||||||
return (1);
|
return (1);
|
||||||
|
|
Loading…
Reference in a new issue