udhcpc: remove workaround for bugs in Win98 dhcp server ("MSFT 98" vendor string)
authorDenys Vlasenko <vda.linux@googlemail.com>
Sat, 5 Nov 2011 00:26:18 +0000 (01:26 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Sat, 5 Nov 2011 00:26:18 +0000 (01:26 +0100)
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>
networking/udhcp/packet.c

index 4d5ff0676eb18123be50c8cb0f6bcac99736d39b..bd754f76681ee6d13e4af8ce3cede378e7157d8b 100644 (file)
@@ -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;
 }