diff options
author | Andrea Barberio <barberio@fb.com> | 2018-10-08 17:17:37 -0700 |
---|---|---|
committer | Andrea Barberio <barberio@fb.com> | 2018-10-08 17:17:37 -0700 |
commit | d831592b8ac464a234a02e66537246d1f6380e89 (patch) | |
tree | 335378a9741e153cf11bcb9fa9b7b906f1496800 | |
parent | 4eedccfd12105dbcde88298e87bbbcf41aa7c1df (diff) |
dhcpv4: fix but in Exchange where a nil packet is returned if send fails
-rw-r--r-- | dhcpv4/client.go | 4 |
1 files 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) |