ndots: produce error on negative numbers
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
b306706062
commit
341845b5f2
2 changed files with 8 additions and 0 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue