bitlk: fix possible leak of description

If metdata contains more than one description fields,
use just the first one.

Fixes OSS-fuzz bug 54682.
This commit is contained in:
Milan Broz
2022-12-30 13:47:20 +01:00
parent 034041a922
commit 7c25db5bf3

View File

@@ -701,7 +701,7 @@ int BITLK_read_sb(struct crypt_device *cd, struct bitlk_metadata *params)
params->volume_header_offset = le64_to_cpu(entry_header.offset);
params->volume_header_size = le64_to_cpu(entry_header.size);
/* volume description (utf-16 string) */
} else if (entry_type == BITLK_ENTRY_TYPE_DESCRIPTION) {
} else if (entry_type == BITLK_ENTRY_TYPE_DESCRIPTION && !params->description) {
if (entry_size < BITLK_ENTRY_HEADER_LEN) {
r = -EINVAL;
goto out;