Use memcmp rather than doing the check by hand.
authoraland <aland>
Sun, 8 Apr 2007 06:29:48 +0000 (06:29 +0000)
committeraland <aland>
Sun, 8 Apr 2007 06:29:48 +0000 (06:29 +0000)
This fixes bug #438

src/modules/rlm_eap/types/rlm_eap_ttls/ttls.c

index 466ef54..b745145 100644 (file)
@@ -350,19 +350,17 @@ static VALUE_PAIR *diameter2vp(SSL *ssl,
                                return NULL;
 
                        } else {
-                               int i;
                                uint8_t challenge[16];
 
                                eapttls_gen_challenge(ssl, challenge,
                                                      sizeof(challenge));
 
-                               for (i = 0; i < vp->length; i++) {
-                                       if (challenge[i] != vp->strvalue[i]) {
-                                               DEBUG2("  TTLS: Tunneled challenge is incorrect");
-                                               pairfree(&first);
-                                               pairfree(&vp);
-                                               return NULL;
-                                       }
+                               if (memcmp(challenge, vp->strvalue,
+                                          vp->length) != 0) {
+                                       DEBUG2("  TTLS: Tunneled challenge is incorrect");
+                                       pairfree(&first);
+                                       pairfree(&vp);
+                                       return NULL;
                                }
                        }
                        break;