Check data_len for internal TLVs
authorAlan T. DeKok <aland@freeradius.org>
Wed, 13 Oct 2010 20:59:59 +0000 (22:59 +0200)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 13 Oct 2010 21:00:35 +0000 (23:00 +0200)
src/modules/rlm_eap/types/rlm_eap_peap/peap.c

index 15e89dd..b77d647 100644 (file)
@@ -383,10 +383,13 @@ static int vp2eap(REQUEST *request, tls_session_t *tls_session, VALUE_PAIR *vp)
 /*
  *     See if there's a TLV in the response.
  */
 /*
  *     See if there's a TLV in the response.
  */
-static int eappeap_check_tlv(REQUEST *request, const uint8_t *data)
+static int eappeap_check_tlv(REQUEST *request, const uint8_t *data,
+                            size_t data_len)
 {
        const eap_packet_t *eap_packet = (const eap_packet_t *) data;
 
 {
        const eap_packet_t *eap_packet = (const eap_packet_t *) data;
 
+       if (data_len < 11) return 0;
+
        /*
         *      Look for success or failure.
         */
        /*
         *      Look for success or failure.
         */
@@ -402,6 +405,8 @@ static int eappeap_check_tlv(REQUEST *request, const uint8_t *data)
                }
        }
 
                }
        }
 
+       RDEBUG("Unknown TLV %02x", data[10]);
+
        return 0;
 }
 
        return 0;
 }
 
@@ -857,7 +862,7 @@ int eappeap_process(EAP_HANDLER *handler, tls_session_t *tls_session)
         *      If we authenticated the user, then it's OK.
         */
        case PEAP_STATUS_SENT_TLV_SUCCESS:
         *      If we authenticated the user, then it's OK.
         */
        case PEAP_STATUS_SENT_TLV_SUCCESS:
-               if (eappeap_check_tlv(request, data)) {
+               if (eappeap_check_tlv(request, data, data_len)) {
                        RDEBUG2("Success");
                        return RLM_MODULE_OK;
                }
                        RDEBUG2("Success");
                        return RLM_MODULE_OK;
                }