From 2543321215d653418f376c48d332c5a264f09ea7 Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Wed, 11 Jan 2012 21:19:46 +0100 Subject: [PATCH] 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 --- msg.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/msg.go b/msg.go index f6667ef5..e6bbab76 100644 --- a/msg.go +++ b/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. lenmsg := len(msg) if n := len(s); n == 0 || s[n-1] != '.' { - return lenmsg, false // This is an error, should be fqdn - // s += "." + //println("hier? s", s) + //return lenmsg, false // This is an error, should be fqdn + s += "." } // 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) } if !ok { - println("dns: overflow packing domain-name") + println("dns: overflow packing domain-name", off) return lenmsg, false } case "size-hex": @@ -1014,7 +1015,7 @@ func (dns *Msg) Pack() (msg []byte, ok bool) { dh.Arcount = uint16(len(extra)) // 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. off := 0