ソースを参照

ndots: produce error on negative numbers

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn 7 年 前
コミット
341845b5f2
2 ファイル変更8 行追加0 行削除
  1. 2 0
      libnetwork/sandbox_dns_unix.go
  2. 6 0
      libnetwork/service_common_test.go

+ 2 - 0
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)
 					}
 				}
 			}

+ 6 - 0
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")
 }