From add14894cac60520f2d08d723bc14012cbe4e6c3 Mon Sep 17 00:00:00 2001 From: Bogdan-Denisenko Date: Mon, 26 Aug 2024 10:12:57 +0000 Subject: [PATCH] Remove zero padding check Signed-off-by: Bogdan-Denisenko --- dhcpv4/options.go | 13 ------------- dhcpv4/options_test.go | 6 +++--- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/dhcpv4/options.go b/dhcpv4/options.go index b31a14b1..18668291 100644 --- a/dhcpv4/options.go +++ b/dhcpv4/options.go @@ -21,11 +21,6 @@ var ( // ErrZeroLengthByteStream is an error that is thrown any time a zero-length // byte stream is encountered. ErrZeroLengthByteStream = errors.New("zero-length byte stream") - - // ErrInvalidOptions is returned when invalid options data is - // encountered during parsing. The data could report an incorrect - // length or have trailing bytes which are not part of the option. - ErrInvalidOptions = errors.New("invalid options data") ) // OptionValue is an interface that all DHCP v4 options adhere to. @@ -161,14 +156,6 @@ func (o Options) fromBytesCheckEnd(data []byte, checkEndOption bool) error { return io.ErrUnexpectedEOF } - // Any bytes left must be padding. - var pad uint8 - for buf.Len() >= 1 { - pad = buf.Read8() - if pad != optPad && pad != optEnd { - return ErrInvalidOptions - } - } return nil } diff --git a/dhcpv4/options_test.go b/dhcpv4/options_test.go index ff11f888..c748c2e9 100644 --- a/dhcpv4/options_test.go +++ b/dhcpv4/options_test.go @@ -255,9 +255,9 @@ func TestOptionsUnmarshal(t *testing.T) { wantError: true, }, { - // Option present after the End is a nono. - input: []byte{byte(OptionEnd), 3}, - wantError: true, + // Option present after the End. + input: []byte{byte(OptionEnd), 3}, + want: Options{}, }, { input: []byte{byte(OptionEnd)},