提交 a4c74e88 编写于 作者: A Andy Polyakov

apps/passwd.c: 32 bits are sufficient to hold ROUNDS_MAX.

Even though C standard defines 'z' modifier, recent mingw compilers break
the contract by defining __STDC_VERSION__ with non-compliant MSVCRT.DLL.
In other words we can't use %zu with mingw, but insteadl of cooking
Reviewed-by: NTim Hudson <tjh@openssl.org>
上级 165f1c3e
...@@ -502,7 +502,7 @@ static char *shacrypt(const char *passwd, const char *magic, const char *salt) ...@@ -502,7 +502,7 @@ static char *shacrypt(const char *passwd, const char *magic, const char *salt)
EVP_MD_CTX *md = NULL, *md2 = NULL; EVP_MD_CTX *md = NULL, *md2 = NULL;
const EVP_MD *sha = NULL; const EVP_MD *sha = NULL;
size_t passwd_len, salt_len, magic_len; size_t passwd_len, salt_len, magic_len;
size_t rounds = 5000; /* Default */ unsigned int rounds = 5000; /* Default */
char rounds_custom = 0; char rounds_custom = 0;
char *p_bytes = NULL; char *p_bytes = NULL;
char *s_bytes = NULL; char *s_bytes = NULL;
...@@ -539,7 +539,7 @@ static char *shacrypt(const char *passwd, const char *magic, const char *salt) ...@@ -539,7 +539,7 @@ static char *shacrypt(const char *passwd, const char *magic, const char *salt)
else if (srounds < ROUNDS_MIN) else if (srounds < ROUNDS_MIN)
rounds = ROUNDS_MIN; rounds = ROUNDS_MIN;
else else
rounds = srounds; rounds = (unsigned int)srounds;
rounds_custom = 1; rounds_custom = 1;
} else { } else {
return NULL; return NULL;
...@@ -556,7 +556,7 @@ static char *shacrypt(const char *passwd, const char *magic, const char *salt) ...@@ -556,7 +556,7 @@ static char *shacrypt(const char *passwd, const char *magic, const char *salt)
OPENSSL_strlcat(out_buf, "$", sizeof out_buf); OPENSSL_strlcat(out_buf, "$", sizeof out_buf);
if (rounds_custom) { if (rounds_custom) {
char tmp_buf[80]; /* "rounds=999999999" */ char tmp_buf[80]; /* "rounds=999999999" */
sprintf(tmp_buf, "rounds=%"OSSLzu, rounds); sprintf(tmp_buf, "rounds=%u", rounds);
OPENSSL_strlcat(out_buf, tmp_buf, sizeof out_buf); OPENSSL_strlcat(out_buf, tmp_buf, sizeof out_buf);
OPENSSL_strlcat(out_buf, "$", sizeof out_buf); OPENSSL_strlcat(out_buf, "$", sizeof out_buf);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册