]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
dhcp6: fix wrong length for IA_PD dhcp6 option
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 16 Mar 2021 15:23:51 +0000 (00:23 +0900)
committerLennart Poettering <lennart@poettering.net>
Tue, 16 Mar 2021 20:29:49 +0000 (21:29 +0100)
Fixes an issue introduced by 73b49d433c2c8e6304c8b82538bd4231d070fce4.

When PrefixDelegationHint= is not set, dhcp6_option_append_pd() sets
wrong length for IA_PD option, as `r` is `-EINVAL`.

Fixes #19021.

src/libsystemd-network/dhcp6-option.c

index 93140160245380ac293256df80b32cff8f43bf38..91162d636bf75ca7ddd22a1dfd057a2f535f0eac 100644 (file)
@@ -257,9 +257,9 @@ int dhcp6_option_append_pd(uint8_t **buf, size_t *buflen, const DHCP6IA *pd, con
                 len += r;
         }
 
-        if (hint_pd_prefix) {
+        if (hint_pd_prefix && hint_pd_prefix->iapdprefix.prefixlen > 0) {
                 r = option_append_pd_prefix(buf, buflen, hint_pd_prefix);
-                if (r < 0 && r != -EINVAL)
+                if (r < 0)
                         return r;
 
                 len += r;