aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2007-01-18 15:42:00 +0000
committervda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2007-01-18 15:42:00 +0000
commit9fe9f86986227e437d0dfdb3c8dbd661a195f6be (patch)
tree5d76c1faae4f411f99b45af9862182bbb89c02c4
parent7696e01d9b514db1e255b1c3cde7fb17f7d73a76 (diff)
downloadbusybox-w32-9fe9f86986227e437d0dfdb3c8dbd661a195f6be.tar.gz
busybox-w32-9fe9f86986227e437d0dfdb3c8dbd661a195f6be.tar.bz2
busybox-w32-9fe9f86986227e437d0dfdb3c8dbd661a195f6be.zip
fix potentially misaligned 32-bit accesses
git-svn-id: svn://busybox.net/trunk/busybox@17365 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r--networking/udhcp/dhcpc.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
index e042da89a..e48e1f25e 100644
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
@@ -23,7 +23,7 @@ static int state;
23 * which holds IPv4 address, and the struct is passed by value (!!) 23 * which holds IPv4 address, and the struct is passed by value (!!)
24 */ 24 */
25static unsigned long requested_ip; /* = 0 */ 25static unsigned long requested_ip; /* = 0 */
26static unsigned long server_addr; 26static uint32_t server_addr;
27static unsigned long timeout; 27static unsigned long timeout;
28static int packet_num; /* = 0 */ 28static int packet_num; /* = 0 */
29static int fd = -1; 29static int fd = -1;
@@ -413,7 +413,8 @@ int udhcpc_main(int argc, char *argv[])
413 if (*message == DHCPOFFER) { 413 if (*message == DHCPOFFER) {
414 temp = get_option(&packet, DHCP_SERVER_ID); 414 temp = get_option(&packet, DHCP_SERVER_ID);
415 if (temp) { 415 if (temp) {
416 server_addr = *(uint32_t*)temp; 416 /* can be misaligned, thus memcpy */
417 memcpy(&server_addr, temp, 4);
417 xid = packet.xid; 418 xid = packet.xid;
418 requested_ip = packet.yiaddr; 419 requested_ip = packet.yiaddr;
419 420
@@ -436,7 +437,9 @@ int udhcpc_main(int argc, char *argv[])
436 bb_error_msg("no lease time with ACK, using 1 hour lease"); 437 bb_error_msg("no lease time with ACK, using 1 hour lease");
437 lease = 60 * 60; 438 lease = 60 * 60;
438 } else { 439 } else {
439 lease = ntohl(*(uint32_t*)temp); 440 /* can be misaligned, thus memcpy */
441 memcpy(&lease, temp, 4);
442 lease = ntohl(lease);
440 } 443 }
441 444
442 /* enter bound state */ 445 /* enter bound state */