mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-05 16:00:05 +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);
|
||||
if (ms) {
|
||||
PBKDF2_temp = (double)iterations * target_ms / ms;
|
||||
if (PBKDF2_temp > UINT32_MAX)
|
||||
return -EINVAL;
|
||||
if (PBKDF2_temp > UINT32_MAX) {
|
||||
r = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
*iter_secs = (uint32_t)PBKDF2_temp;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user