mirror of
https://github.com/miekg/dns.git
synced 2025-12-18 02:01:38 +01:00
Fix the packing failure
non-fqdn don't generate an packing failure. Need to do something about this. Maybe not returning a bool from pack, but a real Error
This commit is contained in:
parent
eb12c526f2
commit
2543321215
9
msg.go
9
msg.go
@ -181,8 +181,9 @@ func PackDomainName(s string, msg []byte, off int, compression map[string]int, c
|
|||||||
// Add trailing dot to canonicalize name.
|
// Add trailing dot to canonicalize name.
|
||||||
lenmsg := len(msg)
|
lenmsg := len(msg)
|
||||||
if n := len(s); n == 0 || s[n-1] != '.' {
|
if n := len(s); n == 0 || s[n-1] != '.' {
|
||||||
return lenmsg, false // This is an error, should be fqdn
|
//println("hier? s", s)
|
||||||
// s += "."
|
//return lenmsg, false // This is an error, should be fqdn
|
||||||
|
s += "."
|
||||||
}
|
}
|
||||||
|
|
||||||
// Each dot ends a segment of the name.
|
// Each dot ends a segment of the name.
|
||||||
@ -490,7 +491,7 @@ func packStructValue(val reflect.Value, msg []byte, off int, compression map[str
|
|||||||
off, ok = PackDomainName(s, msg, off, compression, false && compress)
|
off, ok = PackDomainName(s, msg, off, compression, false && compress)
|
||||||
}
|
}
|
||||||
if !ok {
|
if !ok {
|
||||||
println("dns: overflow packing domain-name")
|
println("dns: overflow packing domain-name", off)
|
||||||
return lenmsg, false
|
return lenmsg, false
|
||||||
}
|
}
|
||||||
case "size-hex":
|
case "size-hex":
|
||||||
@ -1014,7 +1015,7 @@ func (dns *Msg) Pack() (msg []byte, ok bool) {
|
|||||||
dh.Arcount = uint16(len(extra))
|
dh.Arcount = uint16(len(extra))
|
||||||
|
|
||||||
// TODO: still a little too much, but better than 64K...
|
// TODO: still a little too much, but better than 64K...
|
||||||
msg = make([]byte, dns.Len())
|
msg = make([]byte, dns.Len()*2)
|
||||||
|
|
||||||
// Pack it in: header and then the pieces.
|
// Pack it in: header and then the pieces.
|
||||||
off := 0
|
off := 0
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user