Fix real dots in domain names
This commit is contained in:
parent
c7c4d8061e
commit
157c19af4b
4
TODO
4
TODO
|
@ -2,12 +2,10 @@ Todo:
|
|||
* wildcards, in sig gen, sig checking
|
||||
* Private key file parsing use io.Reader (or the like) - NewReader, NewWriter?
|
||||
* Tsig generation for replies (request MAC)
|
||||
* nsupdate
|
||||
* escaped dots in names \.
|
||||
* nsupdate, it's there except for the names
|
||||
|
||||
Longer term:
|
||||
* Parsing from strings, going with goyacc and own lexer
|
||||
* Multi line output?
|
||||
* NSEC and nsec3 closest encloser helper functions
|
||||
* pack/Unpack smaller. EDNS 'n stuff can be folded in
|
||||
* Test impl of nameserver, with a small zone, 1 KSK and online signing
|
||||
|
|
10
msg.go
10
msg.go
|
@ -223,7 +223,15 @@ Loop:
|
|||
if off+c > len(msg) {
|
||||
return "", len(msg), false
|
||||
}
|
||||
s += string(msg[off:off+c]) + "."
|
||||
for j := off; j < off+c; j++ {
|
||||
if msg[j] == '.' {
|
||||
// literal dot, escape it
|
||||
s += "\\."
|
||||
} else {
|
||||
s += string(msg[j])
|
||||
}
|
||||
}
|
||||
s += "."
|
||||
off += c
|
||||
case 0xC0:
|
||||
// pointer to somewhere else in msg.
|
||||
|
|
|
@ -138,7 +138,7 @@ func TestQuadA(t *testing.T) {
|
|||
|
||||
func TestDotInName(t *testing.T) {
|
||||
buf := make([]byte, 20)
|
||||
packDomainName("aa\\.bb.nl", buf, 0)
|
||||
packDomainName("aa\\.bb.nl.", buf, 0)
|
||||
// index 3 must be a real dot
|
||||
if buf[3] != '.' {
|
||||
t.Log("Dot should be a real dot")
|
||||
|
@ -149,9 +149,10 @@ func TestDotInName(t *testing.T) {
|
|||
t.Log("This must have the value 2")
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
dom, _, ok := unpackDomainName(buf, 0)
|
||||
dom, _, _ := unpackDomainName(buf, 0)
|
||||
// printing it should yield the backspace again
|
||||
println(dom)
|
||||
println(ok)
|
||||
if dom != "aa\\.bb.nl." {
|
||||
t.Log("Dot should have been escaped: " + dom)
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue