miekg / dns

DNS library in Go
https://miek.nl/2014/august/16/go-dns-package
BSD 3-Clause "New" or "Revised" License
7.86k stars 1.12k forks source link

IsDomainName: check for escape as last character #1532

Closed miekg closed 4 months ago

miekg commented 5 months ago

Keep track if the escape, if still true when returning isDomainName should return false.

TODO:

There are multiple other places that supposedly also check for this, but they are not called in the parsing.

Fixes: #1528

Signed-off-by: Miek Gieben miek@miek.nl

miekg commented 5 months ago

testing in my tree, yields:

--- FAIL: TestUpdate2NoRdataUnpack (0.00s)
    update2_test.go:72: failed to unpack RR with zero rdata: SOA: dns: overflow unpacking uint32
    update2_test.go:72: failed to unpack RR with zero rdata: TSIG: dns: overflow unpacking uint16
    update2_test.go:72: failed to unpack RR with zero rdata: TKEY: dns: overflow unpacking uint16
FAIL
janik-cloudflare commented 5 months ago

I've applied this to our DNS API repository which has a fairly extensive test suite, and everything looks good!

janik-cloudflare commented 5 months ago

Should still be done in packDomainName as well.

Maybe also on the lexer level so that . 1 IN TXT hello\ is also rejected? (I'd be happy to work on a PR for that, but it might take another two weeks or so.)

miekg commented 4 months ago

yes, please do. I've merged this for now, but there is indeed some followup work to be done