summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko2011-11-05 01:26:18 +0100
committerDenys Vlasenko2011-11-05 01:26:18 +0100
commit3b46fcb95d1276c538f4c84b63eec33cc27ac760 (patch)
treee0fab966012202cd9f76d3cb55545fce7441962e
parentd38ca03946000f0837e9a0e04937499509db54c4 (diff)
downloadbusybox-3b46fcb95d1276c538f4c84b63eec33cc27ac760.zip
busybox-3b46fcb95d1276c538f4c84b63eec33cc27ac760.tar.gz
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>
-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 4d5ff06..bd754f7 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;
}