summaryrefslogtreecommitdiffhomepage
path: root/dhcpv4
diff options
context:
space:
mode:
Diffstat (limited to 'dhcpv4')
-rw-r--r--dhcpv4/option_vivc.go6
-rw-r--r--dhcpv4/option_vivc_test.go7
2 files changed, 10 insertions, 3 deletions
diff --git a/dhcpv4/option_vivc.go b/dhcpv4/option_vivc.go
index 9be8557..7576637 100644
--- a/dhcpv4/option_vivc.go
+++ b/dhcpv4/option_vivc.go
@@ -30,12 +30,12 @@ func ParseOptVIVC(data []byte) (*OptVIVC, error) {
if code != OptionVendorIdentifyingVendorClass {
return nil, fmt.Errorf("expected code %v, got %v", OptionVendorIdentifyingVendorClass, code)
}
- length := int(data[1])
- data = data[2:]
- if length != len(data) {
+ length := int(data[1])
+ if len(data) < 2+length {
return nil, ErrShortByteStream
}
+ data = data[2:length+2]
ids := []VIVCIdentifier{}
for len(data) > 5 {
diff --git a/dhcpv4/option_vivc_test.go b/dhcpv4/option_vivc_test.go
index 14ded61..b290da0 100644
--- a/dhcpv4/option_vivc_test.go
+++ b/dhcpv4/option_vivc_test.go
@@ -56,6 +56,13 @@ func TestParseOptVICO(t *testing.T) {
data[6] = 40
_, err = ParseOptVIVC(data)
require.Error(t, err, "should get error from bad length")
+
+ // Longer than length
+ data[1] = 10
+ data[6] = 5
+ o, err = ParseOptVIVC(data)
+ require.NoError(t, err)
+ require.Equal(t, o.Identifiers[0].Data, []byte("Cisco"))
}
func TestOptVIVCString(t *testing.T) {