8000 Trailing backslash results in non-FQDN targets · Issue #1528 · miekg/dns · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Trailing backslash results in non-FQDN targets #1528
Closed
@janik-cloudflare

Description

@janik-cloudflare

Calling NewRR(". 1 IN CNAME example.com") normally turns example.com into an FQDN, example.com., before storing it in the RR's Target variable.

However, NewRR(". 1 IN CNAME example.com\\") with a trailing backslash results in example.com\., which is not an FQDN since the last dot is escaped.

It seems to me like the parser should either add another dot in these cases, or (perhaps better) reject the trailing backslash with an error.

package main

import (
	"fmt"

	"github.com/miekg/dns"
)

func test(content string) {
	rr, err := dns.NewRR(content)
	if err != nil {
		panic(err)
	}

	target := rr.(*dns.CNAME).Target
	fmt.Printf("target %s is FQDN: %t\n", target, dns.IsFqdn(target))
}

func main() {
	test(`. 1 IN CNAME example.com`)
	test(`. 1 IN CNAME example.com\`)
}
$ go run ./...
target example.com. is FQDN: true
target example.com\. is FQDN: false

This may be related to #1384.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0