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

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