mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-16 21:29:59 +01:00
lib: fix memory leak in crypt_pbkdf_check
There is a memory leak when PBKDF2_temp > UINT32_MAX. Here, we change return to goto out to free key. Signed-off-by: Lixiaokeng <lixiaokeng@huawei.com> Signed-off-by: Linfeilong <linfeilong@huawei.com>
This commit is contained in:
@@ -361,8 +361,10 @@ static int crypt_pbkdf_check(const char *kdf, const char *hash,
|
|||||||
ms = time_ms(&rstart, &rend);
|
ms = time_ms(&rstart, &rend);
|
||||||
if (ms) {
|
if (ms) {
|
||||||
PBKDF2_temp = (double)iterations * target_ms / ms;
|
PBKDF2_temp = (double)iterations * target_ms / ms;
|
||||||
if (PBKDF2_temp > UINT32_MAX)
|
if (PBKDF2_temp > UINT32_MAX) {
|
||||||
return -EINVAL;
|
r = -EINVAL;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
*iter_secs = (uint32_t)PBKDF2_temp;
|
*iter_secs = (uint32_t)PBKDF2_temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user