diff options
-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", |