From: Alan T. DeKok Date: Thu, 14 Jan 2016 22:05:28 +0000 (-0500) Subject: Skip encoding zero-length attributes X-Git-Tag: release_3_0_11~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=77896be0bad744d920f0446cf4bfc41121fd5de8;p=thirdparty%2Ffreeradius-server.git Skip encoding zero-length attributes --- diff --git a/src/lib/radius.c b/src/lib/radius.c index d9d37efdedb..964eb00bd89 100644 --- a/src/lib/radius.c +++ b/src/lib/radius.c @@ -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: @@ -1843,6 +1840,18 @@ int rad_encode(RADIUS_PACKET *packet, RADIUS_PACKET const *original, continue; } + /* + * 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.