diff --git a/msg.go b/msg.go index 7ffab659..19d9147e 100644 --- a/msg.go +++ b/msg.go @@ -564,20 +564,20 @@ func unpackTxtString(msg []byte, offset int) (string, int, error) { s = append(s, `\n`...) default: if b < 32 || b > 127 { // unprintable - var buf [3]byte - bufs := strconv.AppendInt(buf[:0], int64(b), 10) - s = append(s, '\\') - for i := 0; i < 3-len(bufs); i++ { - s = append(s, '0') + var buf [3]byte + bufs := strconv.AppendInt(buf[:0], int64(b), 10) + s = append(s, '\\') + for i := 0; i < 3-len(bufs); i++ { + s = append(s, '0') + } + for _, r := range bufs { + s = append(s, r) + } + } else { + s = append(s, b) } - for _, r := range bufs { - s = append(s, r) - } - } else { - s = append(s, b) } } - } offset += 1 + l return string(s), offset, nil } diff --git a/server_test.go b/server_test.go index fd6a4d0e..b5d57c93 100644 --- a/server_test.go +++ b/server_test.go @@ -68,7 +68,7 @@ func TestServing(t *testing.T) { m := new(Msg) m.SetQuestion("miek.nl.", TypeTXT) r, _, err := c.Exchange(m, addrstr) - if err != nil { + if err != nil || len(r.Extra) == 0 { t.Log("failed to exchange miek.nl", err) t.Fatal() } diff --git a/types.go b/types.go index 98ed46bc..6ea4065a 100644 --- a/types.go +++ b/types.go @@ -830,7 +830,7 @@ func (rr *LOC) String() string { // SIG is identical to RRSIG and nowadays only used for SIG(0), RFC2931. type SIG struct { - RRSIG + RRSIG } type RRSIG struct { @@ -1031,11 +1031,11 @@ func (rr *IPSECKEY) len() int { } type KEY struct { - DNSKEY + DNSKEY } type CDNSKEY struct { - DNSKEY + DNSKEY } type DNSKEY struct { diff --git a/update_test.go b/update_test.go index c871f11d..8206d2d1 100644 --- a/update_test.go +++ b/update_test.go @@ -23,11 +23,14 @@ func TestDynamicUpdateParsing(t *testing.T) { func TestDynamicUpdateUnpack(t *testing.T) { // From https://github.com/miekg/dns/issues/150#issuecomment-62296803 + // It should be an update message for the zone "example.", + // deleting the A RRset "example." and then adding an A record at "example.". + // class ANY, TYPE A buf := []byte{171, 68, 40, 0, 0, 1, 0, 0, 0, 2, 0, 0, 7, 101, 120, 97, 109, 112, 108, 101, 0, 0, 6, 0, 1, 192, 12, 0, 1, 0, 255, 0, 0, 0, 0, 0, 0, 192, 12, 0, 1, 0, 1, 0, 0, 0, 0, 0, 4, 127, 0, 0, 1} msg := new(Msg) err := msg.Unpack(buf) if err != nil { - t.Log("failed to unpack: " + err.Error()) -// t.Fail() + t.Log("failed to unpack: " + err.Error() + "\n" + msg.String())) + t.Fail() } } diff --git a/zscan_rr.go b/zscan_rr.go index f42aebd6..5088cdb5 100644 --- a/zscan_rr.go +++ b/zscan_rr.go @@ -1653,7 +1653,7 @@ func setDSs(h RR_Header, c chan lex, o, f, typ string) (RR, *ParseError, string) } else { rr.DigestType = uint8(i) } - s, e, c1 := endingToString(c, "bad " + typ + " Digest", f) + s, e, c1 := endingToString(c, "bad "+typ+" Digest", f) if e != nil { return nil, e, c1 }