[systemd-devel] [PATCH] fix strict aliasing issue in src/libsystemd-network/sd-dhcp-client.c

Ronny Chevalier chevalier.ronny at gmail.com
Sat Mar 14 06:54:22 PDT 2015


2015-03-11 4:45 GMT+01:00 Shawn Landden <shawn at churchofgit.com>:
> ---
>  src/libsystemd-network/sd-dhcp-client.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/src/libsystemd-network/sd-dhcp-client.c b/src/libsystemd-network/sd-dhcp-client.c
> index 4224e01..a477ccc 100644
> --- a/src/libsystemd-network/sd-dhcp-client.c
> +++ b/src/libsystemd-network/sd-dhcp-client.c
> @@ -1469,7 +1469,7 @@ static int client_receive_message_udp(sd_event_source *s, int fd,
>          _cleanup_free_ DHCPMessage *message = NULL;
>          int buflen = 0, len, r;
>          const struct ether_addr zero_mac = { { 0, 0, 0, 0, 0, 0 } };
> -        const struct ether_addr *expected_chaddr = NULL;
> +        bool expect_chaddr;
>          uint8_t expected_hlen = 0;
>
>          assert(s);
> @@ -1514,11 +1514,11 @@ static int client_receive_message_udp(sd_event_source *s, int fd,
>
>          if (client->arp_type == ARPHRD_ETHER) {
>                  expected_hlen = ETH_ALEN;
> -                expected_chaddr = (const struct ether_addr *) &client->mac_addr;
> +                expect_chaddr = true;
>          } else {
>                 /* Non-ethernet links expect zero chaddr */
>                 expected_hlen = 0;
> -               expected_chaddr = &zero_mac;
> +               expect_chaddr = false;
>          }
>
>          if (message->hlen != expected_hlen) {
> @@ -1526,7 +1526,10 @@ static int client_receive_message_udp(sd_event_source *s, int fd,
>                  return 0;
>          }
>
> -        if (memcmp(&message->chaddr[0], expected_chaddr, ETH_ALEN)) {
> +        if (memcmp(&message->chaddr[0], expect_chaddr ?
> +                                          (void *)&client->mac_addr :
> +                                          (void *)&zero_mac,
> +                                        ETH_ALEN)) {
>                  log_dhcp_client(client, "received chaddr does not match "
>                                  "expected: ignoring");
>                  return 0;
> --
> 2.2.1.209.g41e5f3a
>

Applied, thanks!

(I fixed the commit message to be more inline with the others and shorter)

Ronny


More information about the systemd-devel mailing list