From 2338808f3c33ace65e4019d82ec236036d659e18 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Thu, 28 Jun 2018 20:05:16 +0200 Subject: [PATCH] fix expr.Cmp unmarshaling --- expr/expr.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/expr/expr.go b/expr/expr.go index e055145..5ee854e 100644 --- a/expr/expr.go +++ b/expr/expr.go @@ -181,7 +181,13 @@ func (e *Cmp) unmarshal(data []byte) error { case unix.NFTA_CMP_OP: e.Op = CmpOp(binaryutil.BigEndian.Uint32(attr.Data)) case unix.NFTA_CMP_DATA: - e.Data = attr.Data + attrs, err := netlink.UnmarshalAttributes(attr.Data) + if err != nil { + return err + } + if len(attrs) == 1 && attrs[0].Type == unix.NFTA_DATA_VALUE { + e.Data = attrs[0].Data + } } }