efivar/0012-dp-message-fix-efidp_ipv4_addr-fields-assignment.patch
Petr Šabata 974b936917 RHEL 9.0.0 Alpha bootstrap
The content of this branch was automatically imported from Fedora ELN
with the following as its source:
https://src.fedoraproject.org/rpms/efivar#9f54d8029387895b7b1389d9a9f9e0bf476a027f
2020-10-14 23:58:29 +02:00

45 lines
1.6 KiB
Diff

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