From db63dc738ef8997a0aa51d27bcd58c7ff7ccbfc3 Mon Sep 17 00:00:00 2001 From: Kyriakos Oikonomakos Date: Wed, 27 Jan 2021 17:19:39 +0000 Subject: [PATCH] Add validation for netmask length Ensures a network mask's length will never exceed 32 for IPv4 and 128 for IPv6. --- .../virtual_machine_customize_subresource.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/vsphere/internal/vmworkflow/virtual_machine_customize_subresource.go b/vsphere/internal/vmworkflow/virtual_machine_customize_subresource.go index 7eb1df8c7..3cc218bc8 100644 --- a/vsphere/internal/vmworkflow/virtual_machine_customize_subresource.go +++ b/vsphere/internal/vmworkflow/virtual_machine_customize_subresource.go @@ -230,9 +230,10 @@ func VirtualMachineCustomizeSchema() map[string]*schema.Schema { Description: "The IPv4 address assigned to this network adapter. If left blank, DHCP is used.", }, "ipv4_netmask": { - Type: schema.TypeInt, - Optional: true, - Description: "The IPv4 CIDR netmask for the supplied IP address. Ignored if DHCP is selected.", + Type: schema.TypeInt, + Optional: true, + Description: "The IPv4 CIDR netmask for the supplied IP address. Ignored if DHCP is selected.", + ValidateFunc: validation.IntAtMost(32), }, "ipv6_address": { Type: schema.TypeString, @@ -240,9 +241,10 @@ func VirtualMachineCustomizeSchema() map[string]*schema.Schema { Description: "The IPv6 address assigned to this network adapter. If left blank, default auto-configuration is used.", }, "ipv6_netmask": { - Type: schema.TypeInt, - Optional: true, - Description: "The IPv6 CIDR netmask for the supplied IP address. Ignored if auto-configuration is selected.", + Type: schema.TypeInt, + Optional: true, + Description: "The IPv6 CIDR netmask for the supplied IP address. Ignored if auto-configuration is selected.", + ValidateFunc: validation.IntAtMost(128), }, }}, },