summaryrefslogtreecommitdiffhomepage
path: root/dhcpv6/dhcpv6.go
diff options
context:
space:
mode:
authorAnatole Denis <natolumin@unverle.fr>2019-10-03 20:51:12 +0200
committerAnatole Denis <natolumin@unverle.fr>2019-10-08 08:56:49 +0200
commit1c72f431b01aa49492752868c3e3c5ad7a6a3d84 (patch)
tree19d8a999696e00e5f6dda1872573d9dd822c225b /dhcpv6/dhcpv6.go
parent998c511a2090c3915d8060d687cb9ec3784fc60b (diff)
dhcpv6: Reject empty messages
The uio library doesn't report errors on a per-operation basis, but accumulates them so they can be checked after a batch of operations in a separate Error() function. Unfortunately this makes it easy to forget, thus parse incorrect messages go-fuzz found immediately that an empty message would be parsed without error, and reserialize to a different message (one with some bytes of zeros) Signed-off-by: Anatole Denis <natolumin@unverle.fr>
Diffstat (limited to 'dhcpv6/dhcpv6.go')
-rw-r--r--dhcpv6/dhcpv6.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/dhcpv6/dhcpv6.go b/dhcpv6/dhcpv6.go
index 7505dfc..576293d 100644
--- a/dhcpv6/dhcpv6.go
+++ b/dhcpv6/dhcpv6.go
@@ -79,6 +79,9 @@ func RelayMessageFromBytes(data []byte) (*RelayMessage, error) {
func FromBytes(data []byte) (DHCPv6, error) {
buf := uio.NewBigEndianBuffer(data)
messageType := MessageType(buf.Read8())
+ if buf.Error() != nil {
+ return nil, buf.Error()
+ }
if messageType == MessageTypeRelayForward || messageType == MessageTypeRelayReply {
return RelayMessageFromBytes(data)