]> git.ozlabs.org Git - ppp.git/blobdiff - pppd/chap-new.c
pppd: Fix SIGSEGV in EAP-TLS code when TLS verify method is not specified
[ppp.git] / pppd / chap-new.c
index fab82800a7b33950935c8b13a1be41a0982b45dd..10e4507386e277fbdb6413e46bdd80f61a0b783f 100644 (file)
@@ -166,6 +166,18 @@ chap_register_digest(struct chap_digest_type *dp)
        chap_digests = dp;
 }
 
+/*
+ * Lookup a digest type by code
+ */
+struct chap_digest_type *
+chap_find_digest(int digest_code) {
+       struct chap_digest_type *dp = NULL;
+       for (dp = chap_digests; dp != NULL; dp = dp->next)
+               if (dp->code == digest_code)
+                       break;
+       return dp;
+}
+
 /*
  * chap_lowerup - we can start doing stuff now.
  */
@@ -210,9 +222,8 @@ chap_auth_peer(int unit, char *our_name, int digest_code)
                error("CHAP: peer authentication already started!");
                return;
        }
-       for (dp = chap_digests; dp != NULL; dp = dp->next)
-               if (dp->code == digest_code)
-                       break;
+
+       dp = chap_find_digest(digest_code);
        if (dp == NULL)
                fatal("CHAP digest 0x%x requested but not available",
                      digest_code);