From d831592b8ac464a234a02e66537246d1f6380e89 Mon Sep 17 00:00:00 2001 From: Andrea Barberio Date: Mon, 8 Oct 2018 17:17:37 -0700 Subject: dhcpv4: fix but in Exchange where a nil packet is returned if send fails --- dhcpv4/client.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dhcpv4/client.go b/dhcpv4/client.go index 6f296e0..e753b55 100644 --- a/dhcpv4/client.go +++ b/dhcpv4/client.go @@ -125,7 +125,7 @@ func MakeListeningSocket(ifname string) (int, error) { // error is returned, and the list of DHCPv4 objects will be shorted than 4, // containing all the sent and received DHCPv4 messages. func (c *Client) Exchange(ifname string, discover *DHCPv4, modifiers ...Modifier) ([]*DHCPv4, error) { - conversation := make([]*DHCPv4, 1) + conversation := make([]*DHCPv4, 0) var err error // Get our file descriptor for the broadcast socket. @@ -148,7 +148,7 @@ func (c *Client) Exchange(ifname string, discover *DHCPv4, modifiers ...Modifier for _, mod := range modifiers { discover = mod(discover) } - conversation[0] = discover + conversation = append(conversation, discover) // Offer offer, err := BroadcastSendReceive(sfd, rfd, discover, c.ReadTimeout, c.WriteTimeout, MessageTypeOffer) -- cgit v1.2.3