aboutsummaryrefslogtreecommitdiff
path: root/networking/udhcp
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2011-11-05 01:26:18 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2011-11-05 01:26:18 +0100
commit3b46fcb95d1276c538f4c84b63eec33cc27ac760 (patch)
treee0fab966012202cd9f76d3cb55545fce7441962e /networking/udhcp
parentd38ca03946000f0837e9a0e04937499509db54c4 (diff)
downloadbusybox-w32-3b46fcb95d1276c538f4c84b63eec33cc27ac760.tar.gz
busybox-w32-3b46fcb95d1276c538f4c84b63eec33cc27ac760.tar.bz2
busybox-w32-3b46fcb95d1276c538f4c84b63eec33cc27ac760.zip
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 <vda.linux@googlemail.com>
Diffstat (limited to 'networking/udhcp')
-rw-r--r--networking/udhcp/packet.c34
1 files 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)
81int FAST_FUNC udhcp_recv_kernel_packet(struct dhcp_packet *packet, int fd) 81int FAST_FUNC udhcp_recv_kernel_packet(struct dhcp_packet *packet, int fd)
82{ 82{
83 int bytes; 83 int bytes;
84 unsigned char *vendor;
85 84
86 memset(packet, 0, sizeof(*packet)); 85 memset(packet, 0, sizeof(*packet));
87 bytes = safe_read(fd, packet, sizeof(*packet)); 86 bytes = safe_read(fd, packet, sizeof(*packet));
@@ -90,42 +89,15 @@ int FAST_FUNC udhcp_recv_kernel_packet(struct dhcp_packet *packet, int fd)
90 return bytes; /* returns -1 */ 89 return bytes; /* returns -1 */
91 } 90 }
92 91
93 if (packet->cookie != htonl(DHCP_MAGIC)) { 92 if (bytes < offsetof(struct dhcp_packet, options)
93 || packet->cookie != htonl(DHCP_MAGIC)
94 ) {
94 bb_info_msg("Packet with bad magic, ignoring"); 95 bb_info_msg("Packet with bad magic, ignoring");
95 return -2; 96 return -2;
96 } 97 }
97 log1("Received a packet"); 98 log1("Received a packet");
98 udhcp_dump_packet(packet); 99 udhcp_dump_packet(packet);
99 100
100 if (packet->op == BOOTREQUEST) {
101 vendor = udhcp_get_option(packet, DHCP_VENDOR);
102 if (vendor) {
103#if 0
104 static const char broken_vendors[][8] = {
105 "MSFT 98",
106 ""
107 };
108 int i;
109 for (i = 0; broken_vendors[i][0]; i++) {
110 if (vendor[OPT_LEN - OPT_DATA] == (uint8_t)strlen(broken_vendors[i])
111 && strncmp((char*)vendor, broken_vendors[i], vendor[OPT_LEN - OPT_DATA]) == 0
112 ) {
113 log1("Broken client (%s), forcing broadcast replies",
114 broken_vendors[i]);
115 packet->flags |= htons(BROADCAST_FLAG);
116 }
117 }
118#else
119 if (vendor[OPT_LEN - OPT_DATA] == (uint8_t)(sizeof("MSFT 98")-1)
120 && memcmp(vendor, "MSFT 98", sizeof("MSFT 98")-1) == 0
121 ) {
122 log1("Broken client (%s), forcing broadcast replies", "MSFT 98");
123 packet->flags |= htons(BROADCAST_FLAG);
124 }
125#endif
126 }
127 }
128
129 return bytes; 101 return bytes;
130} 102}
131 103