提交 cf115059 编写于 作者: R Rich Felker

in crypt-sha*, reject excessive rounds as error rather than clamping

the reference implementation clamps rounds to [1000,999999999]. we
further limited rounds to at most 9999999 as a defense against extreme
run times, but wrongly clamped instead of treating out-of-bounds
values as an error, thereby producing implementation-specific hash
results. fixing this should not break anything since values of rounds
this high are not useful anyway.
上级 ef2b5e9f
......@@ -230,7 +230,7 @@ static char *sha256crypt(const char *key, const char *setting, char *output)
if (u < ROUNDS_MIN)
r = ROUNDS_MIN;
else if (u > ROUNDS_MAX)
r = ROUNDS_MAX;
return 0;
else
r = u;
/* needed when rounds is zero prefixed or out of bounds */
......
......@@ -252,7 +252,7 @@ static char *sha512crypt(const char *key, const char *setting, char *output)
if (u < ROUNDS_MIN)
r = ROUNDS_MIN;
else if (u > ROUNDS_MAX)
r = ROUNDS_MAX;
return 0;
else
r = u;
/* needed when rounds is zero prefixed or out of bounds */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册