From 68ad1959024cccdfadb67ad56a9fc86cb18854d5 Mon Sep 17 00:00:00 2001 From: Alexander Tischenko Date: Wed, 3 Apr 2019 17:54:34 +0300 Subject: 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. --- dhcpv4/options.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'dhcpv4') 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 } } -- cgit v1.2.3