From 2ffbcc9f9ad930fee2df53238b3244b7c3e6bb91 Mon Sep 17 00:00:00 2001 From: Chris Hanna Date: Tue, 2 May 2017 14:11:13 -0400 Subject: [PATCH] LU-9430 utils: fix logic errors and putchar in sk_name2hmac() In the sk_name2hmac function in lgss_sk.c, there are a couple minor errors: bad usage of strcmp(), use of putchar() instead of assigning a lowercased value, and use of a logical OR instead of AND. These errors would prevent proper creation of shared keys in certain circumstances. Signed-off-by: Chris Hanna Change-Id: I16462f15201626f194e1b452acf3a1e63dbf0ed7 Reviewed-on: https://review.whamcloud.com/26920 Tested-by: Jenkins Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Tested-by: Maloo --- lustre/utils/gss/lgss_sk.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lustre/utils/gss/lgss_sk.c b/lustre/utils/gss/lgss_sk.c index 825146e..d036450 100644 --- a/lustre/utils/gss/lgss_sk.c +++ b/lustre/utils/gss/lgss_sk.c @@ -83,15 +83,15 @@ enum cfs_crypto_hash_alg sk_name2hmac(char *name) /* convert to lower case */ while (name[i]) { - putchar(tolower(name[i])); + name[i] = tolower(name[i]); i++; } - if (strcmp(name, "none")) + if (strcmp(name, "none") == 0) return CFS_HASH_ALG_NULL; algo = cfs_crypto_hash_alg(name); - if ((algo != CFS_HASH_ALG_SHA256) || + if ((algo != CFS_HASH_ALG_SHA256) && (algo != CFS_HASH_ALG_SHA512)) return SK_HMAC_INVALID; -- 1.8.3.1