dhcp/systemd: ensure aligned memory access in ip6_start() for duid
It probably was no problem in practice, because very likely the chunk of memory was aligned already. Also, drop non helpful comment and fix whitespace.
This commit is contained in:
@@ -29,6 +29,7 @@
|
|||||||
#include <net/if_arp.h>
|
#include <net/if_arp.h>
|
||||||
|
|
||||||
#include "nm-utils/nm-dedup-multi.h"
|
#include "nm-utils/nm-dedup-multi.h"
|
||||||
|
#include "nm-utils/unaligned.h"
|
||||||
|
|
||||||
#include "nm-utils.h"
|
#include "nm-utils.h"
|
||||||
#include "nm-dhcp-utils.h"
|
#include "nm-dhcp-utils.h"
|
||||||
@@ -878,14 +879,13 @@ ip6_start (NMDhcpClient *client,
|
|||||||
GBytes *hwaddr;
|
GBytes *hwaddr;
|
||||||
const char *hostname;
|
const char *hostname;
|
||||||
int r, i;
|
int r, i;
|
||||||
const guint16 *duid_arr;
|
const guint8 *duid_arr;
|
||||||
gsize duid_len;
|
gsize duid_len;
|
||||||
|
|
||||||
g_assert (priv->client4 == NULL);
|
g_assert (priv->client4 == NULL);
|
||||||
g_assert (priv->client6 == NULL);
|
g_assert (priv->client6 == NULL);
|
||||||
g_return_val_if_fail (duid != NULL, FALSE);
|
g_return_val_if_fail (duid != NULL, FALSE);
|
||||||
|
|
||||||
G_STATIC_ASSERT_EXPR (sizeof (duid_arr[0]) == 2);
|
|
||||||
duid_arr = g_bytes_get_data (duid, &duid_len);
|
duid_arr = g_bytes_get_data (duid, &duid_len);
|
||||||
if (!duid_arr || duid_len < 2)
|
if (!duid_arr || duid_len < 2)
|
||||||
g_return_val_if_reached (FALSE);
|
g_return_val_if_reached (FALSE);
|
||||||
@@ -909,12 +909,9 @@ ip6_start (NMDhcpClient *client,
|
|||||||
if (nm_dhcp_client_get_info_only (client))
|
if (nm_dhcp_client_get_info_only (client))
|
||||||
sd_dhcp6_client_set_information_request (priv->client6, 1);
|
sd_dhcp6_client_set_information_request (priv->client6, 1);
|
||||||
|
|
||||||
/* NM stores the entire DUID which includes the uint16 "type", while systemd
|
|
||||||
* wants the type passed separately from the following data.
|
|
||||||
*/
|
|
||||||
r = sd_dhcp6_client_set_duid (priv->client6,
|
r = sd_dhcp6_client_set_duid (priv->client6,
|
||||||
ntohs (duid_arr[0]),
|
unaligned_read_be16 (&duid_arr[0]),
|
||||||
&duid_arr[1],
|
&duid_arr[2],
|
||||||
duid_len - 2);
|
duid_len - 2);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
_LOGW ("failed to set DUID (%d)", r);
|
_LOGW ("failed to set DUID (%d)", r);
|
||||||
|
Reference in New Issue
Block a user