Limit lengths of strings in packets. Fixes CID #1206505
authorAlan T. DeKok <aland@freeradius.org>
Sun, 27 Apr 2014 12:59:09 +0000 (08:59 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 2 May 2014 13:57:47 +0000 (14:57 +0100)
src/modules/proto_vmps/vqp.c

index 73e34d8..fda1b01 100644 (file)
@@ -506,15 +506,27 @@ int vqp_decode(RADIUS_PACKET *packet)
 
                default:
                case PW_TYPE_OCTETS:
-                       pairmemcpy(vp, ptr, length);
+                       if (length < 1024) {
+                               pairmemcpy(vp, ptr, length);
+                       } else {
+                               pairmemcpy(vp, ptr, 1024);
+                       }
                        break;
 
                case PW_TYPE_STRING:
-                       vp->length = length;
-                       vp->vp_strvalue = p = talloc_array(vp, char, vp->length + 1);
-                       vp->type = VT_DATA;
-                       memcpy(p, ptr, vp->length);
-                       p[vp->length] = '\0';
+                       if (length < 1024) {
+                               vp->length = length;
+                               vp->vp_strvalue = p = talloc_array(vp, char, vp->length + 1);
+                               vp->type = VT_DATA;
+                               memcpy(p, ptr, vp->length);
+                               p[vp->length] = '\0';
+                       } else {
+                               vp->length = 1024;
+                               vp->vp_strvalue = p = talloc_array(vp, char, 1025);
+                               vp->type = VT_DATA;
+                               memcpy(p, ptr, vp->length);
+                               p[vp->length] = '\0';
+                       }
                        break;
                }
                ptr += length;