summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--dhcpv4/option_userclass.go2
-rw-r--r--dhcpv4/option_userclass_test.go10
2 files changed, 11 insertions, 1 deletions
diff --git a/dhcpv4/option_userclass.go b/dhcpv4/option_userclass.go
index f7e4d7f..f8a081f 100644
--- a/dhcpv4/option_userclass.go
+++ b/dhcpv4/option_userclass.go
@@ -58,7 +58,7 @@ func (op *OptUserClass) String() string {
func ParseOptUserClass(data []byte) (*OptUserClass, error) {
opt := OptUserClass{}
- if len(data) < 4 {
+ if len(data) < 3 {
return nil, ErrShortByteStream
}
code := OptionCode(data[0])
diff --git a/dhcpv4/option_userclass_test.go b/dhcpv4/option_userclass_test.go
index 0e74ee1..72cf131 100644
--- a/dhcpv4/option_userclass_test.go
+++ b/dhcpv4/option_userclass_test.go
@@ -62,6 +62,16 @@ func TestParseOptUserClassMicrosoft(t *testing.T) {
require.Equal(t, []byte("linuxboot"), opt.UserClasses[0])
}
+func TestParseOptUserClassMicrosoftShort(t *testing.T) {
+ expected := []byte{
+ 77, 1, 'l',
+ }
+ opt, err := ParseOptUserClass(expected)
+ require.NoError(t, err)
+ require.Equal(t, 1, len(opt.UserClasses))
+ require.Equal(t, []byte("l"), opt.UserClasses[0])
+}
+
func TestParseOptUserClassMicrosoftLongerThanLength(t *testing.T) {
expected := []byte{
77, 9, 'l', 'i', 'n', 'u', 'x', 'b', 'o', 'o', 't', 'X',