summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrea Barberio <barberio@fb.com>2018-10-08 17:17:37 -0700
committerAndrea Barberio <barberio@fb.com>2018-10-08 17:17:37 -0700
commitd831592b8ac464a234a02e66537246d1f6380e89 (patch)
tree335378a9741e153cf11bcb9fa9b7b906f1496800
parent4eedccfd12105dbcde88298e87bbbcf41aa7c1df (diff)
dhcpv4: fix but in Exchange where a nil packet is returned if send fails
-rw-r--r--dhcpv4/client.go4
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)