ndots: produce error on negative numbers

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2018-06-29 01:22:17 +02:00
parent b306706062
commit 341845b5f2
2 changed files with 8 additions and 0 deletions

View file

@ -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)
}
}
}

View file

@ -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")
}