Blame 0012-dp-message-fix-efidp_ipv4_addr-fields-assignment.patch

7da9f5b
From 836461e480e2249de134efeaef79588cab045d5c Mon Sep 17 00:00:00 2001
7da9f5b
From: Javier Martinez Canillas <javierm@redhat.com>
7da9f5b
Date: Tue, 5 Mar 2019 17:23:36 +0100
7da9f5b
Subject: [PATCH 12/86] dp-message: fix efidp_ipv4_addr fields assignment
7da9f5b
7da9f5b
The efidp_ipv4_addr structure has some 4-byte array fields to store IPv4
7da9f5b
addresses and network mask. But the efidp_make_ipv4() function wrongly
7da9f5b
casts these as a char * before dereferencing them to store a value.
7da9f5b
7da9f5b
Instead, cast it to a uint32_t * so the 32-bit value is correctly stored.
7da9f5b
7da9f5b
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
7da9f5b
---
7da9f5b
 src/dp-message.c | 8 ++++----
7da9f5b
 1 file changed, 4 insertions(+), 4 deletions(-)
7da9f5b
7da9f5b
diff --git a/src/dp-message.c b/src/dp-message.c
7da9f5b
index 6b8e9072594..55fa7810439 100644
7da9f5b
--- a/src/dp-message.c
7da9f5b
+++ b/src/dp-message.c
7da9f5b
@@ -678,16 +678,16 @@ efidp_make_ipv4(uint8_t *buf, ssize_t size, uint32_t local, uint32_t remote,
7da9f5b
 					EFIDP_MSG_IPv4, sizeof (*ipv4));
7da9f5b
 	ssize_t req = sizeof (*ipv4);
7da9f5b
 	if (size && sz == req) {
7da9f5b
-		*((char *)ipv4->local_ipv4_addr) = htonl(local);
7da9f5b
-		*((char *)ipv4->remote_ipv4_addr) = htonl(remote);
7da9f5b
+		*((uint32_t *)ipv4->local_ipv4_addr) = htonl(local);
7da9f5b
+		*((uint32_t *)ipv4->remote_ipv4_addr) = htonl(remote);
7da9f5b
 		ipv4->local_port = htons(local_port);
7da9f5b
 		ipv4->remote_port = htons(remote_port);
7da9f5b
 		ipv4->protocol = htons(protocol);
7da9f5b
 		ipv4->static_ip_addr = 0;
7da9f5b
 		if (is_static)
7da9f5b
 			ipv4->static_ip_addr = 1;
7da9f5b
-		*((char *)ipv4->gateway) = htonl(gateway);
7da9f5b
-		*((char *)ipv4->netmask) = htonl(netmask);
7da9f5b
+		*((uint32_t *)ipv4->gateway) = htonl(gateway);
7da9f5b
+		*((uint32_t *)ipv4->netmask) = htonl(netmask);
7da9f5b
 	}
7da9f5b
 
7da9f5b
 	if (sz < 0)
7da9f5b
-- 
7da9f5b
2.24.1
7da9f5b