From 54a4f223ba5000c4084d74c99e03988be9c71254 Mon Sep 17 00:00:00 2001 From: Chip Black Date: Sat, 22 Mar 2014 17:11:12 -0500 Subject: [PATCH] More pedantic type fixing and a return fall-through bug --- common/auth.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/common/auth.c b/common/auth.c index 9053a26..ef548ec 100644 --- a/common/auth.c +++ b/common/auth.c @@ -18,7 +18,7 @@ int auth_set_password(const char *username, const char *password) { char filename[FILENAME_MAX]; - unsigned char pwhash[SCRYPT_OUTPUT_SIZE]; + uint8_t pwhash[SCRYPT_OUTPUT_SIZE]; uint8_t salt[SCRYPT_SALT_SIZE]; int fd, n, r; @@ -184,13 +184,13 @@ int auth_check_password_v1(const char *username, const char *password) { unsigned char givenpw[SCRYPT_OUTPUT_SIZE]; int r; - if (auth_get_password(username, epw) == 0) + if (auth_get_password(username, (char *)epw) == 0) return 0; if (auth_get_salt(username, esalt) == 0) return 0; - r = crypto_scrypt(password, strlen(password), esalt, SCRYPT_SALT_SIZE, SCRYPT_N, SCRYPT_r, SCRYPT_p, givenpw, SCRYPT_OUTPUT_SIZE); + r = crypto_scrypt((const uint8_t *)password, strlen(password), esalt, SCRYPT_SALT_SIZE, SCRYPT_N, SCRYPT_r, SCRYPT_p, givenpw, SCRYPT_OUTPUT_SIZE); if (r != 0) { fprintf(stderr, "Failure in scrypt for %s\n", username); return 0; @@ -218,6 +218,8 @@ int auth_check_password(const char *username, const char *password) { case 1: return auth_check_password_v1(username, password); } + fprintf(stderr, "auth_check_password fell through. Bad password version?\n"); + return 0; } void hexify(char *dst, char *src, int len) { @@ -231,7 +233,7 @@ void hexify(char *dst, char *src, int len) { } char *create_random_token() { - unsigned char buf[TOKEN_SIZE]; + char buf[TOKEN_SIZE]; char *token; int rand_fd; -- 2.25.1