summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2023-11-15 13:46:31 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2023-11-15 14:41:02 +0900
commitfdf759e3ae0d190c533f6e38decd3be8c53f46cc (patch)
treef9a9cf07d5d603af3856c86d3b292232c89d7f7c
parentdhcp: fix maximum DUID size (diff)
downloadsystemd-fdf759e3ae0d190c533f6e38decd3be8c53f46cc.tar.xz
systemd-fdf759e3ae0d190c533f6e38decd3be8c53f46cc.zip
sd-dhcp6-client: fix DUID data length passed to hexmem()
Fixes a bug introduced by 6b7d5b6eaf9029b88771ae0ba3cf3c95adb3c24d.
-rw-r--r--src/libsystemd-network/sd-dhcp6-client.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libsystemd-network/sd-dhcp6-client.c b/src/libsystemd-network/sd-dhcp6-client.c
index 08b8676850a..c339dfbec2e 100644
--- a/src/libsystemd-network/sd-dhcp6-client.c
+++ b/src/libsystemd-network/sd-dhcp6-client.c
@@ -276,7 +276,7 @@ int sd_dhcp6_client_duid_as_string(
int r;
assert_return(client, -EINVAL);
- assert_return(client->duid_len > 0, -ENODATA);
+ assert_return(client->duid_len > offsetof(struct duid, raw.data), -ENODATA);
assert_return(duid, -EINVAL);
v = duid_type_to_string(be16toh(client->duid.type));
@@ -290,7 +290,7 @@ int sd_dhcp6_client_duid_as_string(
return -ENOMEM;
}
- t = hexmem(&client->duid.raw.data, client->duid_len);
+ t = hexmem(client->duid.raw.data, client->duid_len - offsetof(struct duid, raw.data));
if (!t)
return -ENOMEM;