Handle label ending in an escaped dot in PackDomain
This commit is contained in:
parent
158454ada4
commit
4bf3023c78
6
msg.go
6
msg.go
|
@ -255,7 +255,7 @@ func packDomainName(s string, msg []byte, off int, compression map[string]int, c
|
||||||
// Emit sequence of counted strings, chopping at dots.
|
// Emit sequence of counted strings, chopping at dots.
|
||||||
begin := 0
|
begin := 0
|
||||||
bs := []byte(s)
|
bs := []byte(s)
|
||||||
ro_bs, bs_fresh := s, true
|
ro_bs, bs_fresh, escaped_dot := s, true, false
|
||||||
for i := 0; i < ls; i++ {
|
for i := 0; i < ls; i++ {
|
||||||
if bs[i] == '\\' {
|
if bs[i] == '\\' {
|
||||||
for j := i; j < ls-1; j++ {
|
for j := i; j < ls-1; j++ {
|
||||||
|
@ -275,12 +275,13 @@ func packDomainName(s string, msg []byte, off int, compression map[string]int, c
|
||||||
}
|
}
|
||||||
ls -= 2
|
ls -= 2
|
||||||
}
|
}
|
||||||
|
escaped_dot = bs[i] == '.'
|
||||||
bs_fresh = false
|
bs_fresh = false
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if bs[i] == '.' {
|
if bs[i] == '.' {
|
||||||
if i > 0 && bs[i-1] == '.' {
|
if i > 0 && bs[i-1] == '.' && !escaped_dot {
|
||||||
// two dots back to back is not legal
|
// two dots back to back is not legal
|
||||||
return lenmsg, labels, ErrRdata
|
return lenmsg, labels, ErrRdata
|
||||||
}
|
}
|
||||||
|
@ -334,6 +335,7 @@ func packDomainName(s string, msg []byte, off int, compression map[string]int, c
|
||||||
labels++
|
labels++
|
||||||
begin = i + 1
|
begin = i + 1
|
||||||
}
|
}
|
||||||
|
escaped_dot = false
|
||||||
}
|
}
|
||||||
// Root label is special
|
// Root label is special
|
||||||
if len(bs) == 1 && bs[0] == '.' {
|
if len(bs) == 1 && bs[0] == '.' {
|
||||||
|
|
Loading…
Reference in New Issue