]> granicus.if.org Git - curl/commitdiff
nss: inspect returnvalue of token check
authorDaniel Gustafsson <daniel@yesql.se>
Fri, 12 Jul 2019 14:13:31 +0000 (16:13 +0200)
committerJay Satiro <raysatiro@yahoo.com>
Wed, 17 Jul 2019 04:52:24 +0000 (00:52 -0400)
PK11_IsPresent() checks for the token for the given slot is available,
and sets needlogin flags for the PK11_Authenticate() call.  Should it
return false, we should however treat it as an error and bail out.

Closes https://github.com/curl/curl/pull/4110

lib/vtls/nss.c

index 85b851ff8de0f40e1c3a17455b28ebab628abae5..482fd5e99a15d769a02959abc7d14b5783f202ad 100644 (file)
@@ -691,7 +691,10 @@ static CURLcode nss_load_key(struct connectdata *conn, int sockindex,
   tmp = SECMOD_WaitForAnyTokenEvent(pem_module, 0, 0);
   if(tmp)
     PK11_FreeSlot(tmp);
-  PK11_IsPresent(slot);
+  if(!PK11_IsPresent(slot)) {
+    PK11_FreeSlot(slot);
+    return CURLE_SSL_CERTPROBLEM;
+  }
 
   status = PK11_Authenticate(slot, PR_TRUE, SSL_SET_OPTION(key_passwd));
   PK11_FreeSlot(slot);