Add warning message about packets being too long
authorAlan T. DeKok <aland@freeradius.org>
Wed, 25 Aug 2010 12:11:39 +0000 (14:11 +0200)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 25 Aug 2010 12:11:39 +0000 (14:11 +0200)
Conflicts:

src/lib/radius.c

src/lib/radius.c

index 112e35d..be4124f 100644 (file)
@@ -937,23 +937,8 @@ int rad_vp2attr(const RADIUS_PACKET *packet, const RADIUS_PACKET *original,
         *      RFC format attributes take the fast path.
         */
        if (vp->vendor == 0) {
-               len = rad_vp2rfc(packet, original, secret, vp,
-                                vp->attribute, start, room);
-               if (len < 0) return -1;
-
-               /*
-                *      RFC 2865 section 5 says that zero-length
-                *      attributes MUST NOT be sent.
-                *
-                *      ... and the WiMAX forum ignores
-                *      this... because of one vendor.  Don't they
-                *      have anything better to do with their time?
-                */
-               if ((len == 0) &&
-                   (vp->attribute != PW_CHARGEABLE_USER_IDENTITY)) return 0;
-
-               return len;
-
+               return rad_vp2rfc(packet, original, secret, vp,
+                                 vp->attribute, start, room);
        }
 
        /*
@@ -1290,6 +1275,16 @@ int rad_encode(RADIUS_PACKET *packet, const RADIUS_PACKET *original,
 
                if (len < 0) return -1;
 
+               /*
+                *      Failed to encode the attribute, likely because
+                *      the packet is full.
+                */
+               if ((len == 0) &&
+                   (total_length > (sizeof(data) - 2 - reply->length))) {
+                       DEBUG("WARNING: Attributes are too long for packet.  Discarding data past %d bytes", total_length);
+                       break;
+               }
+
        next:
                ptr += len;
                total_length += len;