From 97ac7895b423edbaa1944062542ea9f76faa7f06 Mon Sep 17 00:00:00 2001 From: Pablo Mazzini Date: Fri, 9 Nov 2018 13:20:15 +0000 Subject: return nil vendor data --- dhcpv4/ztp/ztp.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'dhcpv4/ztp/ztp.go') diff --git a/dhcpv4/ztp/ztp.go b/dhcpv4/ztp/ztp.go index 3d19bc3..ecd6469 100644 --- a/dhcpv4/ztp/ztp.go +++ b/dhcpv4/ztp/ztp.go @@ -42,7 +42,7 @@ func parseV4VendorClass(packet *dhcpv4.DHCPv4) (*VendorData, error) { case strings.HasPrefix(vc, "Arista;"): p := strings.Split(vc, ";") if len(p) < 4 { - return vd, errVendorOptionMalformed + return nil, errVendorOptionMalformed } vd.VendorName = p[0] @@ -54,7 +54,7 @@ func parseV4VendorClass(packet *dhcpv4.DHCPv4) (*VendorData, error) { case strings.HasPrefix(vc, "ZPESystems:"): p := strings.Split(vc, ":") if len(p) < 3 { - return vd, errVendorOptionMalformed + return nil, errVendorOptionMalformed } vd.VendorName = p[0] @@ -77,6 +77,8 @@ func parseV4VendorClass(packet *dhcpv4.DHCPv4) (*VendorData, error) { // No separator was found. Attempt serial number from the hostname if opt := packet.GetOneOption(dhcpv4.OptionHostName); opt != nil { vd.Serial = opt.(*dhcpv4.OptHostName).HostName + } else { + return nil, errVendorOptionMalformed } } else { vd.Serial = vc[sepIdx+1:] -- cgit v1.2.3