Simplified patch from b4c873
authorAlan T. DeKok <aland@freeradius.org>
Fri, 30 Jan 2009 10:20:32 +0000 (11:20 +0100)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 30 Jan 2009 10:20:32 +0000 (11:20 +0100)
src/lib/vqp.c

index 7255600..7667293 100644 (file)
@@ -506,15 +506,9 @@ int vqp_decode(RADIUS_PACKET *packet)
                default:
                case PW_TYPE_OCTETS:
                case PW_TYPE_STRING:
-                       if (length < MAX_VMPS_LEN) {
-                               memcpy(vp->vp_octets, ptr, length);
-                               vp->length = length;
-                               vp->vp_octets[length] = '\0';
-                       } else {
-                               memcpy(vp->vp_octets, ptr, MAX_VMPS_LEN);
-                               vp->length = MAX_VMPS_LEN;
-                               vp->vp_octets[MAX_VMPS_LEN] = '\0';
-                       }
+                       vp->length = (length > MAX_VMPS_LEN) ? MAX_VMPS_LEN : length;
+                       memcpy(vp->vp_octets, ptr, length);
+                       vp->vp_octets[length] = '\0';
                        break;
                }
                ptr += length;