Skip to content

Commit

Permalink
Merge pull request #546 from Bogdan-Denisenko/remove-padding-check
Browse files Browse the repository at this point in the history
Remove zero padding check
  • Loading branch information
pmazzini authored Aug 27, 2024
2 parents b105c29 + add1489 commit c3c2d84
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 16 deletions.
13 changes: 0 additions & 13 deletions dhcpv4/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
}

Expand Down
6 changes: 3 additions & 3 deletions dhcpv4/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)},
Expand Down

0 comments on commit c3c2d84

Please sign in to comment.