summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--dhcpv4/bsdp/bsdp.go4
-rw-r--r--dhcpv4/bsdp/bsdp_test.go11
2 files changed, 13 insertions, 2 deletions
diff --git a/dhcpv4/bsdp/bsdp.go b/dhcpv4/bsdp/bsdp.go
index 2909ccd..3402b0c 100644
--- a/dhcpv4/bsdp/bsdp.go
+++ b/dhcpv4/bsdp/bsdp.go
@@ -160,7 +160,7 @@ func NewReplyForInformList(inform *dhcpv4.DHCPv4, config ReplyConfig) (*dhcpv4.D
if config.DefaultImage == nil {
return nil, errors.New("NewReplyForInformList: no default boot image ID set")
}
- if len(config.Images) == 0 {
+ if config.Images == nil || len(config.Images) == 0 {
return nil, errors.New("NewReplyForInformList: no boot images provided")
}
reply, err := dhcpv4.NewReplyFromRequest(inform)
@@ -199,7 +199,7 @@ func NewReplyForInformSelect(inform *dhcpv4.DHCPv4, config ReplyConfig) (*dhcpv4
if config.SelectedImage == nil {
return nil, errors.New("NewReplyForInformSelect: no selected boot image ID set")
}
- if len(config.Images) == 0 {
+ if config.Images == nil || len(config.Images) == 0 {
return nil, errors.New("NewReplyForInformSelect: no boot images provided")
}
reply, err := dhcpv4.NewReplyFromRequest(inform)
diff --git a/dhcpv4/bsdp/bsdp_test.go b/dhcpv4/bsdp/bsdp_test.go
index f457631..fc1aedf 100644
--- a/dhcpv4/bsdp/bsdp_test.go
+++ b/dhcpv4/bsdp/bsdp_test.go
@@ -80,6 +80,11 @@ func TestNewReplyForInformList_NoImages(t *testing.T) {
DefaultImage: &fakeImage,
})
require.Error(t, err)
+
+ _, err = NewReplyForInformList(inform, ReplyConfig{
+ Images: nil,
+ SelectedImage: &fakeImage,
+ })
}
// TODO (get9): clean up when #99 lands.
@@ -186,6 +191,12 @@ func TestNewReplyForInformSelect_NoImages(t *testing.T) {
SelectedImage: &fakeImage,
})
require.Error(t, err)
+
+ _, err = NewReplyForInformSelect(inform, ReplyConfig{
+ Images: nil,
+ SelectedImage: &fakeImage,
+ })
+ require.Error(t, err)
}
func TestNewReplyForInformSelect(t *testing.T) {