If we add a dot to a name, be sure to remove one from the length
This commit is contained in:
parent
cb4d52c110
commit
77b60231e7
18
defaults.go
18
defaults.go
|
@ -205,11 +205,15 @@ func IsDomainName(s string) (uint8, uint8, bool) { // copied from net package.
|
||||||
if l == 0 || l > 255 {
|
if l == 0 || l > 255 {
|
||||||
return 0, 0, false
|
return 0, 0, false
|
||||||
}
|
}
|
||||||
// Simplify checking loop: make the name end in a dot
|
longer := 0
|
||||||
// Don't call Fqdn() to save another len(s)
|
// Simplify checking loop: make the name end in a dot.
|
||||||
|
// Don't call Fqdn() to save another len(s).
|
||||||
|
// Keep in mind that if we do this, we report a longer
|
||||||
|
// length
|
||||||
if s[l-1] != '.' {
|
if s[l-1] != '.' {
|
||||||
s += "."
|
s += "."
|
||||||
l++
|
l++
|
||||||
|
longer = 1
|
||||||
}
|
}
|
||||||
last := byte('.')
|
last := byte('.')
|
||||||
ok := false // ok once we've seen a letter
|
ok := false // ok once we've seen a letter
|
||||||
|
@ -219,7 +223,7 @@ func IsDomainName(s string) (uint8, uint8, bool) { // copied from net package.
|
||||||
c := s[i]
|
c := s[i]
|
||||||
switch {
|
switch {
|
||||||
default:
|
default:
|
||||||
return 0, uint8(l), false
|
return 0, uint8(l - longer), false
|
||||||
case 'a' <= c && c <= 'z' || 'A' <= c && c <= 'Z' || c == '_' || c == '*':
|
case 'a' <= c && c <= 'z' || 'A' <= c && c <= 'Z' || c == '_' || c == '*':
|
||||||
ok = true
|
ok = true
|
||||||
partlen++
|
partlen++
|
||||||
|
@ -231,27 +235,27 @@ func IsDomainName(s string) (uint8, uint8, bool) { // copied from net package.
|
||||||
case c == '-':
|
case c == '-':
|
||||||
// byte before dash cannot be dot
|
// byte before dash cannot be dot
|
||||||
if last == '.' {
|
if last == '.' {
|
||||||
return 0, uint8(l), false
|
return 0, uint8(l - longer), false
|
||||||
}
|
}
|
||||||
partlen++
|
partlen++
|
||||||
case c == '.':
|
case c == '.':
|
||||||
// byte before dot cannot be dot, dash
|
// byte before dot cannot be dot, dash
|
||||||
if last == '.' || last == '-' {
|
if last == '.' || last == '-' {
|
||||||
return 0, uint8(l), false
|
return 0, uint8(l - longer), false
|
||||||
}
|
}
|
||||||
if last == '\\' { // Ok, escaped dot.
|
if last == '\\' { // Ok, escaped dot.
|
||||||
partlen++
|
partlen++
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if partlen > 63 || partlen == 0 {
|
if partlen > 63 || partlen == 0 {
|
||||||
return 0, uint8(l), false
|
return 0, uint8(l - longer), false
|
||||||
}
|
}
|
||||||
partlen = 0
|
partlen = 0
|
||||||
labels++
|
labels++
|
||||||
}
|
}
|
||||||
last = c
|
last = c
|
||||||
}
|
}
|
||||||
return labels, uint8(l), ok
|
return labels, uint8(l - longer), ok
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsFqdn checks if a domain name is fully qualified
|
// IsFqdn checks if a domain name is fully qualified
|
||||||
|
|
2
zscan.go
2
zscan.go
|
@ -166,6 +166,8 @@ func parseZone(r io.Reader, f string, t chan Token, include int) {
|
||||||
t <- Token{Error: &ParseError{f, "bad owner name", l}}
|
t <- Token{Error: &ParseError{f, "bad owner name", l}}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
println(l.token)
|
||||||
|
println(len(l.token), ld)
|
||||||
if h.Name[ld-1] != '.' {
|
if h.Name[ld-1] != '.' {
|
||||||
h.Name += origin
|
h.Name += origin
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue