diff --git a/libnetwork/sandbox_dns_unix.go b/libnetwork/sandbox_dns_unix.go index 4df8224478..3641f60f7c 100644 --- a/libnetwork/sandbox_dns_unix.go +++ b/libnetwork/sandbox_dns_unix.go @@ -374,6 +374,8 @@ dnsOpt: // if the user sets ndots, use the user setting sb.ndotsSet = true break dnsOpt + } else { + return fmt.Errorf("invalid number for ndots option: %v", num) } } } diff --git a/libnetwork/service_common_test.go b/libnetwork/service_common_test.go index ab87cea779..6ff14983c3 100644 --- a/libnetwork/service_common_test.go +++ b/libnetwork/service_common_test.go @@ -103,4 +103,10 @@ func TestDNSOptions(t *testing.T) { require.NoError(t, err) err = sb2.(*sandbox).rebuildDNS() require.EqualError(t, err, "invalid number for ndots option: foobar") + + sb2.(*sandbox).config.dnsOptionsList = []string{"ndots:-1"} + err = sb2.(*sandbox).setupDNS() + require.NoError(t, err) + err = sb2.(*sandbox).rebuildDNS() + require.EqualError(t, err, "invalid number for ndots option: -1") }