]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Set limits on string/octet attributes
authorAlan T. DeKok <aland@freeradius.org>
Mon, 23 May 2011 10:15:09 +0000 (12:15 +0200)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 23 May 2011 11:22:17 +0000 (13:22 +0200)
src/lib/valuepair.c

index 1a557c64a0d7413efb67527a675f5e1449b3e4d0..8d8ed531b2266e02e666be9beb73a3f6881aa0ec 100644 (file)
@@ -1511,10 +1511,20 @@ static VALUE_PAIR *pairmake_any(const char *attribute, const char *value,
                vp->type = PW_TYPE_OCTETS;
                /* FALL-THROUGH */
                
-       case PW_TYPE_STRING:
        case PW_TYPE_OCTETS:
        case PW_TYPE_ABINARY:
                vp->length = size >> 1;
+               if (vp->length > sizeof(vp->vp_octets)) {
+                       vp->length = sizeof(vp->vp_octets);
+               }
+               break;
+
+       case PW_TYPE_STRING:
+               vp->length = size >> 1;
+               memset(&vp->vp_strvalue, 0, sizeof(vp->vp_strvalue));
+               if (vp->length >= sizeof(vp->vp_strvalue)) {
+                       vp->length = sizeof(vp->vp_strvalue) - 1;
+               }
                break;
        }