Fix TXT packing and unpacking
This commit is contained in:
parent
2c44133163
commit
c30821fece
2
Makefile
2
Makefile
|
@ -9,7 +9,7 @@ EXAMPLES=mx \
|
|||
q \
|
||||
|
||||
ex:
|
||||
for i in $(EXAMPLES); do go build dns/ex/$$i; done
|
||||
for i in $(EXAMPLES); do echo $$i; go build dns/ex/$$i; done
|
||||
|
||||
clean:
|
||||
rm -f $(EXAMPLES)
|
||||
|
|
10
msg.go
10
msg.go
|
@ -651,15 +651,17 @@ func unpackStructValue(val reflect.Value, msg []byte, off int) (off1 int, ok boo
|
|||
return lenmsg, false
|
||||
}
|
||||
txt = append(txt, string(msg[off+1:off+l]))
|
||||
off += l
|
||||
println("ADDING", string(msg[off+1:off+l]))
|
||||
off += l+1
|
||||
if off < rdlength {
|
||||
// More
|
||||
goto Txts
|
||||
}
|
||||
fv.Set(reflect.ValueOf(txt))
|
||||
case "opt": // EDNS
|
||||
println("SETING", len(txt))
|
||||
case "opt": // edns0
|
||||
if off+2 > lenmsg {
|
||||
// This is an ENDNS0 (OPT Record) with no rdata
|
||||
// This is an EDNS0 (OPT Record) with no rdata
|
||||
// We can savely return here.
|
||||
break
|
||||
}
|
||||
|
@ -703,7 +705,7 @@ func unpackStructValue(val reflect.Value, msg []byte, off int) (off1 int, ok boo
|
|||
}
|
||||
|
||||
if off+2 > lenmsg {
|
||||
println("dns: overflow unpacking NSEC 22")
|
||||
println("dns: overflow unpacking NSEC")
|
||||
return lenmsg, false
|
||||
}
|
||||
nsec := make([]uint16, 0)
|
||||
|
|
7
types.go
7
types.go
|
@ -380,6 +380,7 @@ func (rr *RR_TXT) Header() *RR_Header {
|
|||
func (rr *RR_TXT) String() string {
|
||||
s := rr.Hdr.String()
|
||||
for i, s1 := range rr.Txt {
|
||||
println("HALLO")
|
||||
if i > 0 {
|
||||
s += " " + "\"" + s1 + "\""
|
||||
} else {
|
||||
|
@ -390,7 +391,11 @@ func (rr *RR_TXT) String() string {
|
|||
}
|
||||
|
||||
func (rr *RR_TXT) Len() int {
|
||||
return rr.Hdr.Len() + len(rr.Txt)
|
||||
l := rr.Hdr.Len()
|
||||
for _, t := range rr.Txt {
|
||||
l += len(t)
|
||||
}
|
||||
return l
|
||||
}
|
||||
|
||||
type RR_SRV struct {
|
||||
|
|
Loading…
Reference in New Issue