Whamcloud - gitweb
LU-9430 utils: fix logic errors and putchar in sk_name2hmac() 20/26920/2
authorChris Hanna <hannac@iu.edu>
Tue, 2 May 2017 18:11:13 +0000 (14:11 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 9 May 2017 03:44:03 +0000 (03:44 +0000)
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 <hannac@iu.edu>
Change-Id: I16462f15201626f194e1b452acf3a1e63dbf0ed7
Reviewed-on: https://review.whamcloud.com/26920
Tested-by: Jenkins
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
lustre/utils/gss/lgss_sk.c

index 825146e..d036450 100644 (file)
@@ -83,15 +83,15 @@ enum cfs_crypto_hash_alg sk_name2hmac(char *name)
 
        /* convert to lower case */
        while (name[i]) {
 
        /* convert to lower case */
        while (name[i]) {
-               putchar(tolower(name[i]));
+               name[i] = tolower(name[i]);
                i++;
        }
 
                i++;
        }
 
-       if (strcmp(name, "none"))
+       if (strcmp(name, "none") == 0)
                return CFS_HASH_ALG_NULL;
 
        algo = cfs_crypto_hash_alg(name);
                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;
 
            (algo != CFS_HASH_ALG_SHA512))
                return SK_HMAC_INVALID;