Check return codes. This fixes bug #394
authoraland <aland>
Wed, 18 Oct 2006 19:12:20 +0000 (19:12 +0000)
committeraland <aland>
Wed, 18 Oct 2006 19:12:20 +0000 (19:12 +0000)
src/modules/rlm_digest/rlm_digest.c

index 8216337..e8eb6f7 100644 (file)
@@ -255,7 +255,10 @@ static int digest_authenticate(void *instance, REQUEST *request)
                 *      Set A1 to Digest-HA1 if no User-Password found
                 */
                if (passwd->attribute == PW_DIGEST_HA1) {
-                       lrad_hex2bin(passwd->vp_strvalue, &a1[0], 16);
+                       if (lrad_hex2bin(passwd->vp_strvalue, &a1[0], 16) != 16) {
+                               DEBUG2("rlm_digest: Invalid text in Digest-HA1");
+                               return RLM_MODULE_INVALID;
+                       }
                }
 
        } else if (strcasecmp(algo->vp_strvalue, "MD5-sess") == 0) {
@@ -491,7 +494,10 @@ static int digest_authenticate(void *instance, REQUEST *request)
                return RLM_MODULE_INVALID;
        }
 
-       lrad_hex2bin(&vp->vp_octets[0], &hash[0], vp->length >> 1);
+       if (lrad_hex2bin(&vp->vp_octets[0], &hash[0], vp->length >> 1) != (vp->length >> 1)) {
+               DEBUG2("rlm_digest: Invalid text in Digest-Response");
+               return RLM_MODULE_INVALID;
+       }
 
 #ifndef NDEBUG
        if (debug_flag) {