Don't encode zero-length attributes
authorAlan T. DeKok <aland@freeradius.org>
Sun, 21 Nov 2010 20:37:39 +0000 (21:37 +0100)
committerAlan T. DeKok <aland@freeradius.org>
Sun, 21 Nov 2010 20:37:39 +0000 (21:37 +0100)
except for CUI

src/lib/radius.c
src/tests/rfc.txt

index 5509855..8972ee5 100644 (file)
@@ -1301,6 +1301,11 @@ int rad_vp2rfc(const RADIUS_PACKET *packet,
                return -1;
        }
 
+       if ((vp->length == 0) &&
+           (vp->attribute != PW_CHARGEABLE_USER_IDENTITY)) {
+               return 0;
+       }
+
        return vp2attr_rfc(packet, original, secret, vp, vp->attribute,
                           ptr, room);
 }
index 0866967..64833d0 100644 (file)
 #
 #      encode - reads "Attribute-Name = value", encodes it, and prints
 #               the result as text.
+#              use "-" to encode the output of the last command
 #
 #      decode - reads hex, and decodes it "Attribute-Name = value"
-#               for now, "-" is the only allowed value, and makes it
-#               decode the last hex "data".
+#              use "-" to decode the output of the last command
 #
 #      data - the expected output of the previous command, in ASCII form.
 #             if the actual command output is different, an error message
@@ -93,6 +93,10 @@ data Attr-4 = 0xabcd
 decode 01 02
 data 
 
+# don't encode zero-length attributes
+encode User-Name = ""
+data 
+
 # except for CUI.  Thank you, WiMAX!
 decode 59 02
 data Chargeable-User-Identity = ""