diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-01-18 15:42:00 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-01-18 15:42:00 +0000 |
commit | 74c9d2365a9ada53d8967a280a858acdc98f81fb (patch) | |
tree | 5d76c1faae4f411f99b45af9862182bbb89c02c4 | |
parent | c966ba46a9fb1bf3b3f697f4c838c284ce8ac040 (diff) | |
download | busybox-w32-74c9d2365a9ada53d8967a280a858acdc98f81fb.tar.gz busybox-w32-74c9d2365a9ada53d8967a280a858acdc98f81fb.tar.bz2 busybox-w32-74c9d2365a9ada53d8967a280a858acdc98f81fb.zip |
fix potentially misaligned 32-bit accesses
-rw-r--r-- | networking/udhcp/dhcpc.c | 9 |
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 | */ |
25 | static unsigned long requested_ip; /* = 0 */ | 25 | static unsigned long requested_ip; /* = 0 */ |
26 | static unsigned long server_addr; | 26 | static uint32_t server_addr; |
27 | static unsigned long timeout; | 27 | static unsigned long timeout; |
28 | static int packet_num; /* = 0 */ | 28 | static int packet_num; /* = 0 */ |
29 | static int fd = -1; | 29 | static 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 */ |