From 951af98c7ef7d80c30a19447fbce2a49c7f285f8 Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Tue, 22 Jan 2013 16:41:41 +0100 Subject: [PATCH] fix multiple edns0 option code --- msg.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/msg.go b/msg.go index 8eb5ab7a..294164ed 100644 --- a/msg.go +++ b/msg.go @@ -712,6 +712,7 @@ func unpackStructValue(val reflect.Value, msg []byte, off int) (off1 int, err er fv.Set(reflect.ValueOf(txt)) case `dns:"opt"`: // edns0 rdlength := int(val.FieldByName("Hdr").FieldByName("Rdlength").Uint()) + endrr := off + rdlength if rdlength == 0 { // This is an EDNS0 (OPT Record) with no rdata // We can safely return here. @@ -744,8 +745,11 @@ func unpackStructValue(val reflect.Value, msg []byte, off int) (off1 int, err er e.unpack(msg[off1 : off1+int(optlen)]) edns = append(edns, e) off = off1 + int(optlen) + default: + // do nothing? + off = off1 + int(optlen) } - if off < rdlength { + if off < endrr { goto Option } fv.Set(reflect.ValueOf(edns))