Change eap_vp2packet to use fr_strerror_printf to output its errors
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 2 Oct 2014 09:40:25 +0000 (10:40 +0100)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 2 Oct 2014 09:40:42 +0000 (10:40 +0100)
Because "Malformed EAP message" as an error without any more detail is not useful

src/modules/rlm_eap/libeap/eapcommon.c
src/modules/rlm_eap/libeap/eapsimlib.c
src/modules/rlm_eap/radeapclient.c
src/modules/rlm_eap/rlm_eap.c

index 6ae0ad3..df69cd5 100644 (file)
@@ -308,7 +308,7 @@ eap_packet_raw_t *eap_vp2packet(TALLOC_CTX *ctx, VALUE_PAIR *vps)
         */
        first = pairfind(vps, PW_EAP_MESSAGE, 0, TAG_ANY);
        if (!first) {
-               DEBUG("rlm_eap: EAP-Message not found");
+               fr_strerror_printf("EAP-Message not found");
                return NULL;
        }
 
@@ -316,7 +316,7 @@ eap_packet_raw_t *eap_vp2packet(TALLOC_CTX *ctx, VALUE_PAIR *vps)
         *      Sanity check the length before doing anything.
         */
        if (first->length < 4) {
-               DEBUG("rlm_eap: EAP packet is too short");
+               fr_strerror_printf("EAP packet is too short");
                return NULL;
        }
 
@@ -331,7 +331,7 @@ eap_packet_raw_t *eap_vp2packet(TALLOC_CTX *ctx, VALUE_PAIR *vps)
         *      Take out even more weird things.
         */
        if (len < 4) {
-               DEBUG("rlm_eap: EAP packet has invalid length");
+               fr_strerror_printf("EAP packet has invalid length (less than 4 bytes)");
                return NULL;
        }
 
@@ -344,7 +344,8 @@ eap_packet_raw_t *eap_vp2packet(TALLOC_CTX *ctx, VALUE_PAIR *vps)
                total_len += i->length;
 
                if (total_len > len) {
-                       DEBUG("rlm_eap: Malformed EAP packet.  Length in packet header does not match actual length");
+                       fr_strerror_printf("Malformed EAP packet.  Length in packet header %i, "
+                                          "does not match actual length %i", len, total_len);
                        return NULL;
                }
        }
@@ -353,7 +354,8 @@ eap_packet_raw_t *eap_vp2packet(TALLOC_CTX *ctx, VALUE_PAIR *vps)
         *      If the length is SMALLER, die, too.
         */
        if (total_len < len) {
-               DEBUG("rlm_eap: Malformed EAP packet.  Length in packet header does not match actual length");
+               fr_strerror_printf("Malformed EAP packet.  Length in packet header does not "
+                                  "match actual length");
                return NULL;
        }
 
index b84162a..28fef68 100644 (file)
@@ -378,9 +378,7 @@ int eapsim_checkmac(TALLOC_CTX *ctx, VALUE_PAIR *rvps, uint8_t key[EAPSIM_AUTH_S
         * to have a valid length, which we depend upon.
         */
        e = eap_vp2packet(ctx, rvps);
-       if (!e) {
-               return 0;
-       }
+       if (!e) return 0;
 
        /* make copy big enough for everything */
        elen = (e->length[0] * 256) + e->length[1];
index 9dff2e9..dc48c5e 100644 (file)
@@ -1385,10 +1385,10 @@ static void unmap_eap_methods(RADIUS_PACKET *rep)
 
        /* find eap message */
        e = eap_vp2packet(NULL, rep->vps);
-
-       /* nothing to do! */
-       if(!e) return;
-
+       if (!e) {
+               ERROR("%s", fr_strerror());
+               return;
+       }
        /* create EAP-ID and EAP-CODE attributes to start */
        eap1 = paircreate(rep, PW_EAP_ID, 0);
        eap1->vp_integer = e->id;
index c581063..57cc056 100644 (file)
@@ -284,7 +284,7 @@ static rlm_rcode_t CC_HINT(nonnull) mod_authenticate(void *instance, REQUEST *re
         */
        eap_packet = eap_vp2packet(request, request->packet->vps);
        if (!eap_packet) {
-               RERROR("Malformed EAP Message");
+               RERROR("Malformed EAP Message: %s", fr_strerror());
                return RLM_MODULE_FAIL;
        }
 
@@ -735,7 +735,7 @@ static rlm_rcode_t CC_HINT(nonnull) mod_post_auth(void *instance, REQUEST *reque
 
        eap_packet = eap_vp2packet(request, request->packet->vps);
        if (!eap_packet) {
-               RERROR("Malformed EAP Message");
+               RERROR("Malformed EAP Message: %s", fr_strerror());
                return RLM_MODULE_FAIL;
        }