fix multiple edns0 option code

This commit is contained in:
Miek Gieben 2013-01-22 16:41:41 +01:00
parent 9cd656b377
commit 951af98c7e

6
msg.go
View File

@ -712,6 +712,7 @@ func unpackStructValue(val reflect.Value, msg []byte, off int) (off1 int, err er
fv.Set(reflect.ValueOf(txt)) fv.Set(reflect.ValueOf(txt))
case `dns:"opt"`: // edns0 case `dns:"opt"`: // edns0
rdlength := int(val.FieldByName("Hdr").FieldByName("Rdlength").Uint()) rdlength := int(val.FieldByName("Hdr").FieldByName("Rdlength").Uint())
endrr := off + rdlength
if rdlength == 0 { if rdlength == 0 {
// This is an EDNS0 (OPT Record) with no rdata // This is an EDNS0 (OPT Record) with no rdata
// We can safely return here. // 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)]) e.unpack(msg[off1 : off1+int(optlen)])
edns = append(edns, e) edns = append(edns, e)
off = off1 + int(optlen) off = off1 + int(optlen)
default:
// do nothing?
off = off1 + int(optlen)
} }
if off < rdlength { if off < endrr {
goto Option goto Option
} }
fv.Set(reflect.ValueOf(edns)) fv.Set(reflect.ValueOf(edns))