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:
parent
6135ec89ad
commit
b2f05c2207
2 changed files with 2 additions and 1 deletions
|
@ -211,7 +211,7 @@ func validateDomain(val string) (string, error) {
|
||||||
return "", fmt.Errorf("%s is not a valid domain", val)
|
return "", fmt.Errorf("%s is not a valid domain", val)
|
||||||
}
|
}
|
||||||
ns := domainRegexp.FindSubmatch([]byte(val))
|
ns := domainRegexp.FindSubmatch([]byte(val))
|
||||||
if len(ns) > 0 {
|
if len(ns) > 0 && len(ns[1]) < 255 {
|
||||||
return string(ns[1]), nil
|
return string(ns[1]), nil
|
||||||
}
|
}
|
||||||
return "", fmt.Errorf("%s is not a valid domain", val)
|
return "", fmt.Errorf("%s is not a valid domain", val)
|
||||||
|
|
|
@ -105,6 +105,7 @@ func TestValidateDnsSearch(t *testing.T) {
|
||||||
`foo.bar-.baz`,
|
`foo.bar-.baz`,
|
||||||
`foo.-bar`,
|
`foo.-bar`,
|
||||||
`foo.-bar.baz`,
|
`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 {
|
for _, domain := range valid {
|
||||||
|
|
Loading…
Reference in a new issue