From 9421da315766064c100e75de3341f8fddb90ef23 Mon Sep 17 00:00:00 2001 From: "Nicholas J. Kain" Date: Sun, 14 Nov 2010 01:56:54 -0500 Subject: [PATCH] Don't zero-pad kernel-packet sent dhcp packets. --- ndhc/packet.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ndhc/packet.c b/ndhc/packet.c index 5d66b86..3f6fbbe 100644 --- a/ndhc/packet.c +++ b/ndhc/packet.c @@ -151,8 +151,9 @@ int raw_packet(struct dhcpMessage *payload, uint32_t source_ip, int kernel_packet(struct dhcpMessage *payload, uint32_t source_ip, int source_port, uint32_t dest_ip, int dest_port) { - int opt = 1, fd, result = -1; struct sockaddr_in client; + int opt = 1, fd, result = -1; + unsigned int padding; if ((fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) goto out; @@ -176,7 +177,8 @@ int kernel_packet(struct dhcpMessage *payload, uint32_t source_ip, if (connect(fd, (struct sockaddr *)&client, sizeof(struct sockaddr)) == -1) goto out_fd; - result = safe_write(fd, (const char *)payload, sizeof(struct dhcpMessage)); + padding = DHCP_OPTIONS_BUFSIZE - 1 - end_option(payload->options); + result = safe_write(fd, (const char *)payload, DHCP_SIZE - padding); if (result == -1) log_error("kernel_packet: write failed: %s", strerror(errno)); out_fd: