diff options
author | Pablo Mazzini <pmazzini@gmail.com> | 2018-11-09 13:41:30 +0000 |
---|---|---|
committer | Pablo Mazzini <pmazzini@gmail.com> | 2018-11-09 13:41:30 +0000 |
commit | f92fedbf49c26eea0bfe7bab289d4dda15e2043f (patch) | |
tree | 1cd52b7285b3b58dedc5786c7152671105f7c20a | |
parent | 35e51993410f653ef8ec1052772851f5f7151cab (diff) |
add additional test
-rw-r--r-- | dhcpv4/ztp/ztp.go | 3 | ||||
-rw-r--r-- | dhcpv4/ztp/ztp_test.go | 1 |
2 files changed, 4 insertions, 0 deletions
diff --git a/dhcpv4/ztp/ztp.go b/dhcpv4/ztp/ztp.go index b96c8ae..3a66c4e 100644 --- a/dhcpv4/ztp/ztp.go +++ b/dhcpv4/ztp/ztp.go @@ -79,6 +79,9 @@ func parseV4VendorClass(packet *dhcpv4.DHCPv4) (*VendorData, error) { return nil, errVendorOptionMalformed } } else { + if len(vc) == sepIdx+1 { + return nil, errVendorOptionMalformed + } vd.Serial = vc[sepIdx+1:] vc = vc[:sepIdx] } diff --git a/dhcpv4/ztp/ztp_test.go b/dhcpv4/ztp/ztp_test.go index 40d4754..3fdb951 100644 --- a/dhcpv4/ztp/ztp_test.go +++ b/dhcpv4/ztp/ztp_test.go @@ -40,6 +40,7 @@ func TestParseV4VendorClass(t *testing.T) { }, {name: "juniperNoSerial", vc: "Juniper-qfx10008", fail: true}, {name: "juniperInvalid", vc: "Juniper-", fail: true}, + {name: "juniperInvalid2", vc: "Juniper-qfx99999-", fail: true}, { name: "zpe", vc: "ZPESystems:NSC:001234567", |