OSDN Git Service

dp-message: fix efidp_ipv4_addr fields assignment pie-x86 q-x86 r-x86 android-x86-9.0-r1 android-x86-9.0-r2
authorJavier Martinez Canillas <javierm@redhat.com>
Tue, 5 Mar 2019 16:23:36 +0000 (17:23 +0100)
committerPeter Jones <pjones@redhat.com>
Tue, 5 Mar 2019 18:14:47 +0000 (13:14 -0500)
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

index 6b8e907..55fa781 100644 (file)
@@ -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)