svn commit: trunk/busybox/networking/udhcp

vda at busybox.net vda at busybox.net
Thu Jan 18 15:42:01 UTC 2007


Author: vda
Date: 2007-01-18 07:42:00 -0800 (Thu, 18 Jan 2007)
New Revision: 17365

Log:
fix potentially misaligned 32-bit accesses


Modified:
   trunk/busybox/networking/udhcp/dhcpc.c


Changeset:
Modified: trunk/busybox/networking/udhcp/dhcpc.c
===================================================================
--- trunk/busybox/networking/udhcp/dhcpc.c	2007-01-18 12:39:05 UTC (rev 17364)
+++ trunk/busybox/networking/udhcp/dhcpc.c	2007-01-18 15:42:00 UTC (rev 17365)
@@ -23,7 +23,7 @@
  * which holds IPv4 address, and the struct is passed by value (!!)
  */
 static unsigned long requested_ip; /* = 0 */
-static unsigned long server_addr;
+static uint32_t server_addr;
 static unsigned long timeout;
 static int packet_num; /* = 0 */
 static int fd = -1;
@@ -413,7 +413,8 @@
 				if (*message == DHCPOFFER) {
 					temp = get_option(&packet, DHCP_SERVER_ID);
 					if (temp) {
-						server_addr = *(uint32_t*)temp;
+						/* can be misaligned, thus memcpy */
+						memcpy(&server_addr, temp, 4);
 						xid = packet.xid;
 						requested_ip = packet.yiaddr;
 
@@ -436,7 +437,9 @@
 						bb_error_msg("no lease time with ACK, using 1 hour lease");
 						lease = 60 * 60;
 					} else {
-						lease = ntohl(*(uint32_t*)temp);
+						/* can be misaligned, thus memcpy */
+						memcpy(&lease, temp, 4);
+						lease = ntohl(lease);
 					}
 
 					/* enter bound state */




More information about the busybox-cvs mailing list