Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove zero padding check #546

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading