diff options
author | Alexander Tischenko <tsm@glavset.ru> | 2019-04-03 17:54:34 +0300 |
---|---|---|
committer | insomniac <insomniacslk@users.noreply.github.com> | 2019-04-03 15:54:34 +0100 |
commit | 68ad1959024cccdfadb67ad56a9fc86cb18854d5 (patch) | |
tree | 7f1ecc516e787bac56ab674624ea441f1f344d3d /dhcpv4 | |
parent | d862affa8b379318605a75c0f6f8fd00f8fed238 (diff) |
Allow 0xFF padding in 'End' option (#265)
After investigation on DHCP relaying with BDCOM P3608 GPON OLT switches, i found that 'End' option is not always padded with 0x00, but for some packets is padded by the same 0xFF (End) option.
DHCPv4 fails to parse such type of packets and throws an "Invalid options" error. But Wireshark says that all is just fine with 0xFF padding.
This commit allows to use 0xFF/0x00 End option padding instead of strict 0x00. This allows BDCOM switches relaying mechanism to work with package.
Diffstat (limited to 'dhcpv4')
-rw-r--r-- | dhcpv4/options.go | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/dhcpv4/options.go b/dhcpv4/options.go index 68ce665..4968130 100644 --- a/dhcpv4/options.go +++ b/dhcpv4/options.go @@ -156,8 +156,10 @@ func (o Options) fromBytesCheckEnd(data []byte, checkEndOption bool) error { } // Any bytes left must be padding. + var pad uint8 for buf.Len() >= 1 { - if buf.Read8() != optPad { + pad = buf.Read8() + if pad != optPad && pad != optEnd { return ErrInvalidOptions } } |