Skip to content

Commit

Permalink
ndots: produce error on negative numbers
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
  • Loading branch information
thaJeztah committed Jun 28, 2018
1 parent 5586e22 commit cfa9afd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sandbox_dns_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions service_common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

0 comments on commit cfa9afd

Please sign in to comment.