From 341845b5f25a9405f2036d9833f41aff0c309d67 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Fri, 29 Jun 2018 01:22:17 +0200 Subject: [PATCH] ndots: produce error on negative numbers Signed-off-by: Sebastiaan van Stijn --- libnetwork/sandbox_dns_unix.go | 2 ++ libnetwork/service_common_test.go | 6 ++++++ 2 files changed, 8 insertions(+) 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") }