[Nagiosplug-checkins] nagiosplug/plugins check_dhcp.c,1.6,1.7

Harper Mann harpermann at users.sourceforge.net
Tue Jan 25 10:12:04 CET 2005


Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21966

Modified Files:
	check_dhcp.c 
Log Message:
Tracker:1109261  This was an alignment problem on Solaris.  Linux kernel fixes alignment so this was not seen there.  Memcpy takes care of proper alignment.  Tested on RHEL V3 U3, RHEL V4, FreeBSD 4.10 (Thanks Stanley!) and Solaris 9 with the GNU env.


Index: check_dhcp.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_dhcp.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- check_dhcp.c	30 Dec 2004 00:41:39 -0000	1.6
+++ check_dhcp.c	25 Jan 2005 18:11:21 -0000	1.7
@@ -770,12 +770,21 @@
 			printf("Option: %d (0x%02X)\n",option_type,option_length);
 
 		/* get option data */
-		if(option_type==DHCP_OPTION_LEASE_TIME)
-			dhcp_lease_time=ntohl(*((u_int32_t *)&offer_packet->options[x]));
-		if(option_type==DHCP_OPTION_RENEWAL_TIME)
-			dhcp_renewal_time=ntohl(*((u_int32_t *)&offer_packet->options[x]));
-		if(option_type==DHCP_OPTION_REBINDING_TIME)
-			dhcp_rebinding_time=ntohl(*((u_int32_t *)&offer_packet->options[x]));
+        if(option_type==DHCP_OPTION_LEASE_TIME) {
+            memcpy(&dhcp_lease_time, &offer_packet->options[x],
+                sizeof(dhcp_lease_time));
+            dhcp_lease_time = ntohl(dhcp_lease_time);
+        }
+        if(option_type==DHCP_OPTION_RENEWAL_TIME) {
+            memcpy(&dhcp_renewal_time, &offer_packet->options[x],
+                sizeof(dhcp_renewal_time));
+            dhcp_renewal_time = ntohl(dhcp_renewal_time);
+        }
+        if(option_type==DHCP_OPTION_REBINDING_TIME) {
+            memcpy(&dhcp_rebinding_time, &offer_packet->options[x],
+                sizeof(dhcp_rebinding_time));
+            dhcp_rebinding_time = ntohl(dhcp_rebinding_time);
+        }
 
 		/* skip option data we're ignoring */
 		else





More information about the Commits mailing list