Skip encoding zero-length attributes
authorAlan T. DeKok <aland@freeradius.org>
Thu, 14 Jan 2016 22:05:28 +0000 (17:05 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 14 Jan 2016 22:05:28 +0000 (17:05 -0500)
src/lib/radius.c

index d9d37ef..964eb00 100644 (file)
@@ -881,10 +881,7 @@ static ssize_t vp2data_any(RADIUS_PACKET const *packet,
        case PW_TYPE_STRING:
        case PW_TYPE_OCTETS:
                data = vp->data.ptr;
-               if (!data) {
-                       fr_strerror_printf("ERROR: Cannot encode NULL data for attribute %s", vp->da->name);
-                       return -1;
-               }
+               if (!data) return 0;
                break;
 
        case PW_TYPE_IFID:
@@ -1844,6 +1841,18 @@ int rad_encode(RADIUS_PACKET *packet, RADIUS_PACKET const *original,
                }
 
                /*
+                *      We allow zero-length strings in "unlang", but
+                *      skip them (except for CUI, thanks WiMAX!) on
+                *      all other attributes.
+                */
+               if ((reply->vp_length == 0) &&
+                   (reply->da->vendor == 0) &&
+                   (reply->da->attr != PW_CHARGEABLE_USER_IDENTITY)) {
+                       reply = reply->next;
+                       continue;
+               }
+
+               /*
                 *      Set the Message-Authenticator to the correct
                 *      length and initial value.
                 */