diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-02-04 02:45:40 +0100 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-02-14 06:43:45 +0100 |
commit | 93bd7c4192c9afc41be1b317278a7ed3e829b971 (patch) | |
tree | 23090ac180f0696fc348eb4a81e31673d7f382ba /src/libsystemd-network/sd-dhcp6-lease.c | |
parent | sd-dhcp6-lease: convert assert_return() -> assert() in non-public functions (diff) | |
download | systemd-93bd7c4192c9afc41be1b317278a7ed3e829b971.tar.xz systemd-93bd7c4192c9afc41be1b317278a7ed3e829b971.zip |
sd-dhcp6-lease: reset client or server ID when length is zero
Addresses https://github.com/systemd/systemd/pull/22406#issuecomment-1029391091.
Diffstat (limited to 'src/libsystemd-network/sd-dhcp6-lease.c')
-rw-r--r-- | src/libsystemd-network/sd-dhcp6-lease.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/libsystemd-network/sd-dhcp6-lease.c b/src/libsystemd-network/sd-dhcp6-lease.c index 3cb30348a9..7d6a6f7f9c 100644 --- a/src/libsystemd-network/sd-dhcp6-lease.c +++ b/src/libsystemd-network/sd-dhcp6-lease.c @@ -72,15 +72,16 @@ DHCP6IA *dhcp6_lease_free_ia(DHCP6IA *ia) { } int dhcp6_lease_set_clientid(sd_dhcp6_lease *lease, const uint8_t *id, size_t len) { - uint8_t *clientid; + uint8_t *clientid = NULL; assert(lease); - assert(id); - assert(len > 0); + assert(id || len == 0); - clientid = memdup(id, len); - if (!clientid) - return -ENOMEM; + if (len > 0) { + clientid = memdup(id, len); + if (!clientid) + return -ENOMEM; + } free_and_replace(lease->clientid, clientid); lease->clientid_len = len; @@ -103,15 +104,16 @@ int dhcp6_lease_get_clientid(sd_dhcp6_lease *lease, uint8_t **ret_id, size_t *re } int dhcp6_lease_set_serverid(sd_dhcp6_lease *lease, const uint8_t *id, size_t len) { - uint8_t *serverid; + uint8_t *serverid = NULL; assert(lease); - assert(id); - assert(len > 0); + assert(id || len == 0); - serverid = memdup(id, len); - if (!serverid) - return -ENOMEM; + if (len > 0) { + serverid = memdup(id, len); + if (!serverid) + return -ENOMEM; + } free_and_replace(lease->serverid, serverid); lease->serverid_len = len; |