Merge pull request #149 from jvarho/divide-by-zero-fix

Check r and p against zero before dividing
This commit is contained in:
Frank Denis 2014-05-08 08:07:50 -07:00
commit 4722990ec3
2 changed files with 8 additions and 0 deletions

View File

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

View File

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