Flag bad rdlength as an error

This commit is contained in:
Miek Gieben 2013-02-08 16:39:21 +01:00
parent 78619c08e4
commit 8adb7c519c
3 changed files with 9 additions and 5 deletions

View File

@ -215,8 +215,8 @@ Flags:
doXfr(c, m, nameserver)
continue
}
Redo:
r, rtt, e := c.Exchange(m, nameserver)
Redo:
if e != nil {
fmt.Printf(";; %s\n", e.Error())
continue

5
msg.go
View File

@ -1097,7 +1097,7 @@ func UnpackRR(msg []byte, off int) (rr RR, off1 int, err error) {
}
off, err = UnpackStruct(rr, msg, off0)
if off != end {
return &h, end, nil
return &h, end, &Error{Err: "bad rdlength"}
}
return rr, off, err
}
@ -1306,7 +1306,8 @@ func (dns *Msg) Unpack(msg []byte) (err error) {
}
if off != len(msg) {
// TODO(mg) remove eventually
// println("extra bytes in dns packet", off, "<", len(msg))
// Err: extra bytes in packet
println("dns: extra bytes in dns packet", off, "<", len(msg))
}
return nil
}

View File

@ -519,12 +519,15 @@ func (rr *SPF) Header() *RR_Header { return &rr.Hdr }
func (rr *SPF) Copy() RR { return &SPF{*rr.Hdr.CopyHeader(), rr.Txt} }
func (rr *SPF) String() string {
println("DDSDDSDS")
s := rr.Hdr.String()
println("LENGTH", len(rr.Txt))
for i, s1 := range rr.Txt {
println(i, "DDDSDS")
if i > 0 {
s += " " + "\"" + s1 + "\""
s += " " + strconv.QuoteToASCII(s1)
} else {
s += "\"" + s1 + "\""
s += strconv.QuoteToASCII(s1)
}
}
return s