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

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