From 3b46fcb95d1276c538f4c84b63eec33cc27ac760 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sat, 5 Nov 2011 01:26:18 +0100 Subject: [PATCH] udhcpc: remove workaround for bugs in Win98 dhcp server ("MSFT 98" vendor string) Stats for last three commits: function old new delta udhcpc_main 2635 2646 +11 udhcp_recv_raw_packet 425 414 -11 udhcp_recv_kernel_packet 210 134 -76 packed_usage 28940 28857 -83 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/3 up/down: 11/-170) Total: -159 bytes text data bss dec hex filename 879524 493 7584 887601 d8b31 busybox_old 879340 493 7584 887417 d8a79 busybox_unstripped Signed-off-by: Denys Vlasenko --- networking/udhcp/packet.c | 34 +++------------------------------- 1 file changed, 3 insertions(+), 31 deletions(-) diff --git a/networking/udhcp/packet.c b/networking/udhcp/packet.c index 4d5ff0676..bd754f766 100644 --- a/networking/udhcp/packet.c +++ b/networking/udhcp/packet.c @@ -81,7 +81,6 @@ void FAST_FUNC udhcp_dump_packet(struct dhcp_packet *packet) int FAST_FUNC udhcp_recv_kernel_packet(struct dhcp_packet *packet, int fd) { int bytes; - unsigned char *vendor; memset(packet, 0, sizeof(*packet)); bytes = safe_read(fd, packet, sizeof(*packet)); @@ -90,42 +89,15 @@ int FAST_FUNC udhcp_recv_kernel_packet(struct dhcp_packet *packet, int fd) return bytes; /* returns -1 */ } - if (packet->cookie != htonl(DHCP_MAGIC)) { + if (bytes < offsetof(struct dhcp_packet, options) + || packet->cookie != htonl(DHCP_MAGIC) + ) { bb_info_msg("Packet with bad magic, ignoring"); return -2; } log1("Received a packet"); udhcp_dump_packet(packet); - if (packet->op == BOOTREQUEST) { - vendor = udhcp_get_option(packet, DHCP_VENDOR); - if (vendor) { -#if 0 - static const char broken_vendors[][8] = { - "MSFT 98", - "" - }; - int i; - for (i = 0; broken_vendors[i][0]; i++) { - if (vendor[OPT_LEN - OPT_DATA] == (uint8_t)strlen(broken_vendors[i]) - && strncmp((char*)vendor, broken_vendors[i], vendor[OPT_LEN - OPT_DATA]) == 0 - ) { - log1("Broken client (%s), forcing broadcast replies", - broken_vendors[i]); - packet->flags |= htons(BROADCAST_FLAG); - } - } -#else - if (vendor[OPT_LEN - OPT_DATA] == (uint8_t)(sizeof("MSFT 98")-1) - && memcmp(vendor, "MSFT 98", sizeof("MSFT 98")-1) == 0 - ) { - log1("Broken client (%s), forcing broadcast replies", "MSFT 98"); - packet->flags |= htons(BROADCAST_FLAG); - } -#endif - } - } - return bytes; } -- 2.25.1