Skip to content

Commit c3c2d84

Browse files
authored
Merge pull request #546 from Bogdan-Denisenko/remove-padding-check
Remove zero padding check
2 parents b105c29 + add1489 commit c3c2d84

File tree

2 files changed

+3
-16
lines changed

2 files changed

+3
-16
lines changed

dhcpv4/options.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ var (
2121
// ErrZeroLengthByteStream is an error that is thrown any time a zero-length
2222
// byte stream is encountered.
2323
ErrZeroLengthByteStream = errors.New("zero-length byte stream")
24-
25-
// ErrInvalidOptions is returned when invalid options data is
26-
// encountered during parsing. The data could report an incorrect
27-
// length or have trailing bytes which are not part of the option.
28-
ErrInvalidOptions = errors.New("invalid options data")
2924
)
3025

3126
// OptionValue is an interface that all DHCP v4 options adhere to.
@@ -161,14 +156,6 @@ func (o Options) fromBytesCheckEnd(data []byte, checkEndOption bool) error {
161156
return io.ErrUnexpectedEOF
162157
}
163158

164-
// Any bytes left must be padding.
165-
var pad uint8
166-
for buf.Len() >= 1 {
167-
pad = buf.Read8()
168-
if pad != optPad && pad != optEnd {
169-
return ErrInvalidOptions
170-
}
171-
}
172159
return nil
173160
}
174161

dhcpv4/options_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,9 @@ func TestOptionsUnmarshal(t *testing.T) {
255255
wantError: true,
256256
},
257257
{
258-
// Option present after the End is a nono.
259-
input: []byte{byte(OptionEnd), 3},
260-
wantError: true,
258+
// Option present after the End.
259+
input: []byte{byte(OptionEnd), 3},
260+
want: Options{},
261261
},
262262
{
263263
input: []byte{byte(OptionEnd)},

0 commit comments

Comments
 (0)