1
mirror of https://github.com/jedisct1/libsodium.git synced 2024-12-19 18:15:18 -07:00

Dont expect EFBIG to be returned if a requested allocation is too large

Some environments return funny things such as "function not implemented",
EINVAL or "permission denied" instead.

So, don't assume anything.
This commit is contained in:
Frank Denis 2017-07-12 21:36:33 +02:00
parent b456ff2886
commit 7cfbb5922b
2 changed files with 16 additions and 32 deletions

View File

@ -258,8 +258,7 @@ main(void)
printf("pwhash_str_verify(1) failure\n");
}
str_out[14]++;
if (crypto_pwhash_str_verify(str_out, passwd, strlen(passwd)) != -1 ||
errno != EFBIG) {
if (crypto_pwhash_str_verify(str_out, passwd, strlen(passwd)) != -1) {
printf("pwhash_str_verify(2) failure\n");
}
str_out[14]--;
@ -277,44 +276,37 @@ main(void)
}
if (crypto_pwhash_str_verify("$argon2i$m=65536,t=2,p=1c29tZXNhbHQ"
"$9sTbSlTio3Biev89thdrlKKiCaYsjjYVJxGAL3swxpQ",
"password", 0x100000000ULL) != -1 ||
errno != EFBIG) {
"password", 0x100000000ULL) != -1) {
printf("pwhash_str_verify(invalid(0)) failure\n");
}
if (crypto_pwhash_str_verify("$argon2i$m=65536,t=2,p=1c29tZXNhbHQ"
"$9sTbSlTio3Biev89thdrlKKiCaYsjjYVJxGAL3swxpQ",
"password", strlen("password")) != -1 ||
errno != EFBIG) {
"password", strlen("password")) != -1) {
printf("pwhash_str_verify(invalid(1)) failure %d\n", errno);
}
if (crypto_pwhash_str_verify("$argon2i$m=65536,t=2,p=1$c29tZXNhbHQ"
"9sTbSlTio3Biev89thdrlKKiCaYsjjYVJxGAL3swxpQ",
"password", strlen("password")) != -1 ||
errno != EFBIG) {
"password", strlen("password")) != -1) {
printf("pwhash_str_verify(invalid(2)) failure\n");
}
if (crypto_pwhash_str_verify("$argon2i$m=65536,t=2,p=1$c29tZXNhbHQ"
"$b2G3seW+uPzerwQQC+/E1K50CLLO7YXy0JRcaTuswRo",
"password", strlen("password")) != -1 ||
errno != EFBIG) {
"password", strlen("password")) != -1) {
printf("pwhash_str_verify(invalid(3)) failure\n");
}
if (crypto_pwhash_str_verify("$argon2i$v=19$m=65536,t=2,p=1c29tZXNhbHQ"
"$wWKIMhR9lyDFvRz9YTZweHKfbftvj+qf+YFY4NeBbtA",
"password", strlen("password")) != -1 ||
errno != EFBIG) {
"password", strlen("password")) != -1) {
printf("pwhash_str_verify(invalid(4)) failure\n");
}
if (crypto_pwhash_str_verify("$argon2i$v=19$m=65536,t=2,p=1$c29tZXNhbHQ"
"wWKIMhR9lyDFvRz9YTZweHKfbftvj+qf+YFY4NeBbtA",
"password", strlen("password")) != -1 ||
errno != EFBIG) {
"password", strlen("password")) != -1) {
printf("pwhash_str_verify(invalid(5)) failure\n");
}
if (crypto_pwhash_str_verify("$argon2i$v=19$m=65536,t=2,p=1$c29tZXNhbHQ"
"$8iIuixkI73Js3G1uMbezQXD0b8LG4SXGsOwoQkdAQIM",
"password", strlen("password")) != -1 ||
errno != EFBIG) {
"password", strlen("password")) != -1) {
printf("pwhash_str_verify(invalid(6)) failure\n");
}
if (crypto_pwhash_str_verify(

View File

@ -259,8 +259,7 @@ main(void)
printf("pwhash_argon2id_str_verify(1) failure\n");
}
str_out[14]++;
if (crypto_pwhash_argon2id_str_verify(str_out, passwd, strlen(passwd)) != -1 ||
errno != EFBIG) {
if (crypto_pwhash_argon2id_str_verify(str_out, passwd, strlen(passwd)) != -1) {
printf("pwhash_argon2id_str_verify(2) failure\n");
}
str_out[14]--;
@ -278,44 +277,37 @@ main(void)
}
if (crypto_pwhash_argon2id_str_verify("$argon2i$m=65536,t=2,p=1c29tZXNhbHQ"
"$9sTbSlTio3Biev89thdrlKKiCaYsjjYVJxGAL3swxpQ",
"password", 0x100000000ULL) != -1 ||
errno != EFBIG) {
"password", 0x100000000ULL) != -1) {
printf("pwhash_argon2id_str_verify(invalid(0)) failure\n");
}
if (crypto_pwhash_argon2id_str_verify("$argon2i$m=65536,t=2,p=1c29tZXNhbHQ"
"$9sTbSlTio3Biev89thdrlKKiCaYsjjYVJxGAL3swxpQ",
"password", strlen("password")) != -1 ||
errno != EFBIG) {
"password", strlen("password")) != -1) {
printf("pwhash_argon2id_str_verify(invalid(1)) failure %d\n", errno);
}
if (crypto_pwhash_argon2id_str_verify("$argon2i$m=65536,t=2,p=1$c29tZXNhbHQ"
"9sTbSlTio3Biev89thdrlKKiCaYsjjYVJxGAL3swxpQ",
"password", strlen("password")) != -1 ||
errno != EFBIG) {
"password", strlen("password")) != -1) {
printf("pwhash_argon2id_str_verify(invalid(2)) failure\n");
}
if (crypto_pwhash_argon2id_str_verify("$argon2i$m=65536,t=2,p=1$c29tZXNhbHQ"
"$b2G3seW+uPzerwQQC+/E1K50CLLO7YXy0JRcaTuswRo",
"password", strlen("password")) != -1 ||
errno != EFBIG) {
"password", strlen("password")) != -1) {
printf("pwhash_argon2id_str_verify(invalid(3)) failure\n");
}
if (crypto_pwhash_argon2id_str_verify("$argon2i$v=19$m=65536,t=2,p=1c29tZXNhbHQ"
"$wWKIMhR9lyDFvRz9YTZweHKfbftvj+qf+YFY4NeBbtA",
"password", strlen("password")) != -1 ||
errno != EFBIG) {
"password", strlen("password")) != -1) {
printf("pwhash_argon2id_str_verify(invalid(4)) failure\n");
}
if (crypto_pwhash_argon2id_str_verify("$argon2i$v=19$m=65536,t=2,p=1$c29tZXNhbHQ"
"wWKIMhR9lyDFvRz9YTZweHKfbftvj+qf+YFY4NeBbtA",
"password", strlen("password")) != -1 ||
errno != EFBIG) {
"password", strlen("password")) != -1) {
printf("pwhash_argon2id_str_verify(invalid(5)) failure\n");
}
if (crypto_pwhash_argon2id_str_verify("$argon2i$v=19$m=65536,t=2,p=1$c29tZXNhbHQ"
"$8iIuixkI73Js3G1uMbezQXD0b8LG4SXGsOwoQkdAQIM",
"password", strlen("password")) != -1 ||
errno != EFBIG) {
"password", strlen("password")) != -1) {
printf("pwhash_argon2id_str_verify(invalid(6)) failure\n");
}
if (crypto_pwhash_argon2id_str_verify(