Check r and p against zero before dividing

This commit is contained in:
Jan Varho 2014-05-08 12:48:56 +03:00
parent dabd8fe426
commit 3785fc5cd5
2 changed files with 8 additions and 0 deletions

View File

@ -248,6 +248,10 @@ escrypt_kdf_nosse(escrypt_local_t * local,
errno = EINVAL;
return -1;
}
if (r == 0 || p == 0) {
errno = EINVAL;
return -1;
}
if ((r > SIZE_MAX / 128 / p) ||
#if SIZE_MAX / 256 <= UINT32_MAX
(r > SIZE_MAX / 256) ||

View File

@ -334,6 +334,10 @@ escrypt_kdf_sse(escrypt_local_t * local,
errno = EINVAL;
return -1;
}
if (r == 0 || p == 0) {
errno = EINVAL;
return -1;
}
if ((r > SIZE_MAX / 128 / p) ||
#if SIZE_MAX / 256 <= UINT32_MAX
(r > SIZE_MAX / 256) ||