Merge pull request #11260 from jfrazelle/carry-domain-255

Restrict domain name to 255 characters
This commit is contained in:
Tibor Vass 2015-03-09 14:09:37 -04:00
commit 6ffc57ad5c
2 changed files with 2 additions and 1 deletions

View File

@ -211,7 +211,7 @@ func validateDomain(val string) (string, error) {
return "", fmt.Errorf("%s is not a valid domain", val)
}
ns := domainRegexp.FindSubmatch([]byte(val))
if len(ns) > 0 {
if len(ns) > 0 && len(ns[1]) < 255 {
return string(ns[1]), nil
}
return "", fmt.Errorf("%s is not a valid domain", val)

View File

@ -105,6 +105,7 @@ func TestValidateDnsSearch(t *testing.T) {
`foo.bar-.baz`,
`foo.-bar`,
`foo.-bar.baz`,
`foo.bar.baz.this.should.fail.on.long.name.beause.it.is.longer.thanisshouldbethis.should.fail.on.long.name.beause.it.is.longer.thanisshouldbethis.should.fail.on.long.name.beause.it.is.longer.thanisshouldbethis.should.fail.on.long.name.beause.it.is.longer.thanisshouldbe`,
}
for _, domain := range valid {