1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Restrict domain name to 255 characters

Signed-off-by: Tomáš Hrčka <thrcka@redhat.com>

Docker-DCO-1.1-Signed-off-by: Jessie Frazelle <princess@docker.com> (github: jfrazelle)
This commit is contained in:
Tomáš Hrčka 2014-11-25 12:45:20 +01:00 committed by Jessica Frazelle
parent 6135ec89ad
commit b2f05c2207
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 {