Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b2f05c2

Browse files
humatonjessfraz
authored andcommitted
Restrict domain name to 255 characters
Signed-off-by: Tomáš Hrčka <[email protected]> Docker-DCO-1.1-Signed-off-by: Jessie Frazelle <[email protected]> (github: jfrazelle)
1 parent 6135ec8 commit b2f05c2

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

opts/opts.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ func validateDomain(val string) (string, error) {
211211
return "", fmt.Errorf("%s is not a valid domain", val)
212212
}
213213
ns := domainRegexp.FindSubmatch([]byte(val))
214-
if len(ns) > 0 {
214+
if len(ns) > 0 && len(ns[1]) < 255 {
215215
return string(ns[1]), nil
216216
}
217217
return "", fmt.Errorf("%s is not a valid domain", val)

opts/opts_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ func TestValidateDnsSearch(t *testing.T) {
105105
`foo.bar-.baz`,
106106
`foo.-bar`,
107107
`foo.-bar.baz`,
108+
`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`,
108109
}
109110

110111
for _, domain := range valid {

0 commit comments

Comments
 (0)