From ba7954561beac31baa4e297afd066cb6fb7f09f9 Mon Sep 17 00:00:00 2001 From: Nalin Dahyabhai Date: Dec 15 2010 22:04:30 +0000 Subject: don't bother comparing the configured token name with the token's name if it's NULL (D10059) --- diff --git a/src/keygen-n.c b/src/keygen-n.c index a16c804..abe0f88 100644 --- a/src/keygen-n.c +++ b/src/keygen-n.c @@ -127,10 +127,13 @@ cm_keygen_n_main(int fd, struct cm_store_ca *ca, struct cm_store_entry *entry, token = PK11_GetTokenName(sle->slot); if (token != NULL) { cm_log(3, "Found token '%s'.\n", token); + } else { + cm_log(3, "Found unnamed token.\n"); } if ((entry->cm_key_token == NULL) || (strlen(entry->cm_key_token) == 0) || - (strcmp(entry->cm_key_token, token) == 0)) { + ((token != NULL) && + (strcmp(entry->cm_key_token, token) == 0))) { slot = sle->slot; break; } diff --git a/src/keyiread-n.c b/src/keyiread-n.c index fc08d1c..742c38e 100644 --- a/src/keyiread-n.c +++ b/src/keyiread-n.c @@ -122,10 +122,13 @@ cm_keyiread_n_get_private_key(struct cm_store_entry *entry, int readwrite) token = PK11_GetTokenName(slot); if (token != NULL) { cm_log(3, "Found token '%s'.\n", token); + } else { + cm_log(3, "Found unnamed token.\n"); } /* If this is the wrong token, move on. */ - if ((entry->cm_key_token != NULL) && + if ((token != NULL) && + (entry->cm_key_token != NULL) && (strlen(entry->cm_key_token) > 0) && (strcmp(entry->cm_key_token, token) != 0)) { cm_log(1, "Token is named \"%s\", not \"%s\".\n",