mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-13 11:50:10 +01:00
Free json buffer on error path.
Code should not return allocated buffer if validation fails. (But this does not fix a leak, memory is freed later, it is just more readable.)
This commit is contained in:
@@ -291,6 +291,8 @@ static int hdr_read_disk(struct crypt_device *cd,
|
|||||||
if (hdr_checksum_check(cd, hdr_disk->checksum_alg, hdr_disk,
|
if (hdr_checksum_check(cd, hdr_disk->checksum_alg, hdr_disk,
|
||||||
*json_area, hdr_json_size)) {
|
*json_area, hdr_json_size)) {
|
||||||
log_dbg(cd, "LUKS2 header checksum error (offset %" PRIu64 ").", offset);
|
log_dbg(cd, "LUKS2 header checksum error (offset %" PRIu64 ").", offset);
|
||||||
|
free(*json_area);
|
||||||
|
*json_area = NULL;
|
||||||
r = -EINVAL;
|
r = -EINVAL;
|
||||||
}
|
}
|
||||||
memset(hdr_disk->csum, 0, LUKS2_CHECKSUM_L);
|
memset(hdr_disk->csum, 0, LUKS2_CHECKSUM_L);
|
||||||
|
|||||||
Reference in New Issue
Block a user