File ibacm-no_type_punning.patch of Package ibacm

From: Philipp Thomas <pth@suse.de>
Date: 2012-09-10 12:14:17 +02:00
Subject: input: Fix type punning.
Upstream: submitted

Replace unsafe type punning by cast by two memcpy and a temp variable.

---
 src/acm.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Index: src/acm.c
===================================================================
--- src/acm.c.orig	2013-07-26 06:27:59.000000000 +0200
+++ src/acm.c	2014-08-29 16:52:58.562260193 +0200
@@ -32,6 +32,7 @@
 #  include <config.h>
 #endif /* HAVE_CONFIG_H */
 
+#include <stddef.h>
 #include <stdio.h>
 #include <stdarg.h>
 #include <string.h>
@@ -1605,7 +1606,7 @@ static void acm_process_timeouts(void)
 		DListRemove(entry);
 
 		msg = container_of(entry, struct acm_send_msg, entry);
-		rec = (struct acm_resolve_rec *) ((struct acm_mad *) msg->data)->data;
+		memcpy(rec, msg->data + offsetof(struct acm_mad, data), sizeof(rec));
 
 		acm_format_name(0, log_data, sizeof log_data,
 				rec->dest_type, rec->dest, sizeof rec->dest);
@@ -2740,8 +2741,10 @@ static int acm_parse_osm_fullv1_paths(FI
 		for (i = 0; i < 2; i++) {
 			memset(addr, 0, ACM_MAX_ADDRESS);
 			if (i == 0) {
+				uint16_t ui_addr;
 				addr_type = ACM_ADDRESS_LID;
-				*((uint16_t *) addr) = htons(dlid);
+				ui_addr = htons(dlid);
+				memcpy(&addr, &ui_addr, sizeof(uint16_t));
 			} else {
 				addr_type = ACM_ADDRESS_GID;
 				memcpy(addr, &dgid, sizeof(dgid));
openSUSE Build Service is sponsored by