ixp4xx-2.6/config: Removed the PPP config override to allow PPP modules to be built
[openwrt.git] / package / busybox / patches / 241-udhcpc-oversized_packets.patch
1 Index: busybox-1.4.2/networking/udhcp/packet.c
2 ===================================================================
3 --- busybox-1.4.2.orig/networking/udhcp/packet.c 2007-06-04 13:21:32.289067984 +0200
4 +++ busybox-1.4.2/networking/udhcp/packet.c 2007-06-04 13:21:33.619865672 +0200
5 @@ -107,6 +107,10 @@
6 return ~sum;
7 }
8
9 +int udhcp_get_payload_len(struct dhcpMessage *payload)
10 +{
11 + return sizeof(struct dhcpMessage) - MAX_OPTIONS_LEN + end_option(payload->options) + sizeof(payload->options[0]);
12 +}
13
14 /* Construct a ip/udp header for a packet, and specify the source and dest hardware address */
15 void BUG_sizeof_struct_udp_dhcp_packet_must_be_576(void);
16 @@ -118,6 +122,7 @@
17 int result;
18 struct sockaddr_ll dest;
19 struct udp_dhcp_packet packet;
20 + int p_len = udhcp_get_payload_len(payload);
21
22 fd = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP));
23 if (fd < 0) {
24 @@ -127,6 +132,7 @@
25
26 memset(&dest, 0, sizeof(dest));
27 memset(&packet, 0, sizeof(packet));
28 + memcpy(&(packet.data), payload, p_len);
29
30 dest.sll_family = AF_PACKET;
31 dest.sll_protocol = htons(ETH_P_IP);
32 @@ -144,12 +150,13 @@
33 packet.ip.daddr = dest_ip;
34 packet.udp.source = htons(source_port);
35 packet.udp.dest = htons(dest_port);
36 - packet.udp.len = htons(sizeof(packet.udp) + sizeof(struct dhcpMessage)); /* cheat on the psuedo-header */
37 + p_len += sizeof(packet.udp);
38 + packet.udp.len = htons(p_len);
39 packet.ip.tot_len = packet.udp.len;
40 - memcpy(&(packet.data), payload, sizeof(struct dhcpMessage));
41 - packet.udp.check = udhcp_checksum(&packet, sizeof(struct udp_dhcp_packet));
42 + p_len += sizeof(packet.ip);
43 + packet.udp.check = udhcp_checksum(&packet, p_len);
44
45 - packet.ip.tot_len = htons(sizeof(struct udp_dhcp_packet));
46 + packet.ip.tot_len = htons(p_len);
47 packet.ip.ihl = sizeof(packet.ip) >> 2;
48 packet.ip.version = IPVERSION;
49 packet.ip.ttl = IPDEFTTL;
50 @@ -158,7 +165,7 @@
51 if (sizeof(struct udp_dhcp_packet) != 576)
52 BUG_sizeof_struct_udp_dhcp_packet_must_be_576();
53
54 - result = sendto(fd, &packet, sizeof(struct udp_dhcp_packet), 0,
55 + result = sendto(fd, &packet, p_len, 0,
56 (struct sockaddr *) &dest, sizeof(dest));
57 if (result <= 0) {
58 bb_perror_msg("sendto");
59 @@ -205,7 +212,7 @@
60 return -1;
61 }
62
63 - result = write(fd, payload, sizeof(struct dhcpMessage));
64 + result = write(fd, payload, udhcp_get_payload_len(payload));
65 close(fd);
66 return result;
67 }
68 Index: busybox-1.4.2/networking/udhcp/common.h
69 ===================================================================
70 --- busybox-1.4.2.orig/networking/udhcp/common.h 2007-06-04 13:21:32.297066768 +0200
71 +++ busybox-1.4.2/networking/udhcp/common.h 2007-06-04 13:21:33.620865520 +0200
72 @@ -22,6 +22,8 @@
73 #include <netinet/udp.h>
74 #include <netinet/ip.h>
75
76 +#define MAX_OPTIONS_LEN 308
77 +
78 struct dhcpMessage {
79 uint8_t op;
80 uint8_t htype;
81 @@ -38,7 +40,7 @@
82 uint8_t sname[64];
83 uint8_t file[128];
84 uint32_t cookie;
85 - uint8_t options[308]; /* 312 - cookie */
86 + uint8_t options[MAX_OPTIONS_LEN]; /* 312 - cookie */
87 };
88
89 struct udp_dhcp_packet {
This page took 0.047885 seconds and 5 git commands to generate.