From 7cfbb5922b9de72546090c62e304f3a3d2816eef Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Wed, 12 Jul 2017 21:36:33 +0200 Subject: [PATCH] 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. --- test/default/pwhash.c | 24 ++++++++---------------- test/default/pwhash_argon2id.c | 24 ++++++++---------------- 2 files changed, 16 insertions(+), 32 deletions(-) diff --git a/test/default/pwhash.c b/test/default/pwhash.c index ffef570b..00f3a157 100644 --- a/test/default/pwhash.c +++ b/test/default/pwhash.c @@ -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( diff --git a/test/default/pwhash_argon2id.c b/test/default/pwhash_argon2id.c index 82478b1a..3b37a9eb 100644 --- a/test/default/pwhash_argon2id.c +++ b/test/default/pwhash_argon2id.c @@ -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(