aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--networking/udhcp/packet.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/networking/udhcp/packet.c b/networking/udhcp/packet.c
index 33c9585cf..148f52551 100644
--- a/networking/udhcp/packet.c
+++ b/networking/udhcp/packet.c
@@ -143,8 +143,15 @@ int FAST_FUNC udhcp_send_raw_packet(struct dhcp_packet *dhcp_pkt,
143 * 143 *
144 * In order to work with those buggy servers, 144 * In order to work with those buggy servers,
145 * we truncate packets after end option byte. 145 * we truncate packets after end option byte.
146 *
147 * However, RFC 1542 says "The IP Total Length and UDP Length
148 * must be large enough to contain the minimal BOOTP header of 300 octets".
149 * Thus, we retain enough padding to not go below 300 BOOTP bytes.
150 * Some devices have filters which drop DHCP packets shorter than that.
146 */ 151 */
147 padding = DHCP_OPTIONS_BUFSIZE - 1 - udhcp_end_option(packet.data.options); 152 padding = DHCP_OPTIONS_BUFSIZE - 1 - udhcp_end_option(packet.data.options);
153 if (padding > DHCP_SIZE - 300)
154 padding = DHCP_SIZE - 300;
148 155
149 packet.ip.protocol = IPPROTO_UDP; 156 packet.ip.protocol = IPPROTO_UDP;
150 packet.ip.saddr = source_nip; 157 packet.ip.saddr = source_nip;
@@ -215,6 +222,8 @@ int FAST_FUNC udhcp_send_kernel_packet(struct dhcp_packet *dhcp_pkt,
215 222
216 udhcp_dump_packet(dhcp_pkt); 223 udhcp_dump_packet(dhcp_pkt);
217 padding = DHCP_OPTIONS_BUFSIZE - 1 - udhcp_end_option(dhcp_pkt->options); 224 padding = DHCP_OPTIONS_BUFSIZE - 1 - udhcp_end_option(dhcp_pkt->options);
225 if (padding > DHCP_SIZE - 300)
226 padding = DHCP_SIZE - 300;
218 result = safe_write(fd, dhcp_pkt, DHCP_SIZE - padding); 227 result = safe_write(fd, dhcp_pkt, DHCP_SIZE - padding);
219 msg = "write"; 228 msg = "write";
220 ret_close: 229 ret_close: