diff --git a/msg.go b/msg.go index dbea743f..14fbbfd6 100644 --- a/msg.go +++ b/msg.go @@ -650,7 +650,7 @@ func unpackStructValue(val reflect.Value, msg []byte, off int) (off1 int, ok boo println("dns: failure unpacking txt strings") return lenmsg, false } - txt = append(txt, string(msg[off+1:off+l])) + txt = append(txt, string(msg[off+1:off+l+1])) off += l+1 if off < rdlength { // More diff --git a/parse_test.go b/parse_test.go index 2b59c861..a9c419cc 100644 --- a/parse_test.go +++ b/parse_test.go @@ -202,6 +202,8 @@ func TestQuotes(t *testing.T) { `t.example.com. IN TXT "a bc"`: "t.example.com.\t3600\tIN\tTXT\t\"a bc\"", `t.example.com. IN TXT "a bc"`: "t.example.com.\t3600\tIN\tTXT\t\"a\n bc\"", + `t.example.com. IN TXT "a"`: "t.example.com.\t3600\tIN\tTXT\t\"a\"", + `t.example.com. IN TXT "aa"`: "t.example.com.\t3600\tIN\tTXT\t\"aa\"", `t.example.com. IN TXT "aaa" ;`: "t.example.com.\t3600\tIN\tTXT\t\"aaa\"", `t.example.com. IN TXT "abc" "DEF"`: "t.example.com.\t3600\tIN\tTXT\t\"abc\" \"DEF\"", `t.example.com. IN TXT "abc" ( "DEF" )`: "t.example.com.\t3600\tIN\tTXT\t\"abc\" \"DEF\"",