Handle NOT_SUPPORTED or other errors properly in get_quintuplet
authorMartin Willi <martin@strongswan.org>
Fri, 27 Nov 2009 13:55:20 +0000 (14:55 +0100)
committerMartin Willi <martin@strongswan.org>
Mon, 30 Nov 2009 08:26:35 +0000 (09:26 +0100)
src/charon/sa/authenticators/eap/sim_manager.c

index 4fbb16e..940b25d 100644 (file)
@@ -102,12 +102,18 @@ static status_t card_get_quintuplet(private_sim_manager_t *this,
        while (enumerator->enumerate(enumerator, &card))
        {
                status = card->get_quintuplet(card, id, rand, autn, ck, ik, res, res_len);
-               if (status != FAILED)
+               switch (status)
                {       /* try next on error, but not on INVALID_STATE */
-                       enumerator->destroy(enumerator);
-                       return status;
+                       case SUCCESS:
+                       case INVALID_STATE:
+                               enumerator->destroy(enumerator);
+                               return status;
+                       case NOT_SUPPORTED:
+                       case FAILED:
+                       default:
+                               tried++;
+                               continue;
                }
-               tried++;
        }
        enumerator->destroy(enumerator);
        DBG1(DBG_IKE, "tried %d SIM cards, but none has quintuplets for '%Y'",