summaryrefslogtreecommitdiff
path: root/src/basic
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2018-11-07 15:31:26 +0900
committerGitHub <noreply@github.com>2018-11-07 15:31:26 +0900
commitc6d8bbb66eb5b033fd8809a7d89401d337a5f1c5 (patch)
tree1ecee98fceb4a9c10e6a69d71475cdf34294b5f0 /src/basic
parent13d8a53aaec29eaacec85bfe008e0212d49b1b7a (diff)
downloadsystemd-c6d8bbb66eb5b033fd8809a7d89401d337a5f1c5.tar.gz
systemd-c6d8bbb66eb5b033fd8809a7d89401d337a5f1c5.tar.bz2
systemd-c6d8bbb66eb5b033fd8809a7d89401d337a5f1c5.zip
in-addr-util: make in_addr_default_prefix_from_string() or friend set 0 to prefixlen when family == AF_INET6 (#10665)
Follow-up for a4798d4e6d88c2be2625ce62d8326eaa9b80f2ee. Fixes #10662.
Diffstat (limited to 'src/basic')
-rw-r--r--src/basic/in-addr-util.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/basic/in-addr-util.c b/src/basic/in-addr-util.c
index 4cf6ab6974..6a00de2ef0 100644
--- a/src/basic/in-addr-util.c
+++ b/src/basic/in-addr-util.c
@@ -531,10 +531,13 @@ int in_addr_prefix_from_string_internal(
r = in_addr_parse_prefixlen(family, e+1, &k);
if (r < 0)
return r;
- } else if (family == AF_INET && use_default_prefixlen) {
- r = in4_addr_default_prefixlen(&buffer.in, &k);
- if (r < 0)
- return r;
+ } else if (use_default_prefixlen) {
+ if (family == AF_INET) {
+ r = in4_addr_default_prefixlen(&buffer.in, &k);
+ if (r < 0)
+ return r;
+ } else
+ k = 0;
} else
k = FAMILY_ADDRESS_SIZE(family) * 8;
@@ -579,10 +582,13 @@ int in_addr_prefix_from_string_auto_internal(
r = in_addr_parse_prefixlen(family, e+1, &k);
if (r < 0)
return r;
- } else if (family == AF_INET && use_default_prefixlen) {
- r = in4_addr_default_prefixlen(&buffer.in, &k);
- if (r < 0)
- return r;
+ } else if (use_default_prefixlen) {
+ if (family == AF_INET) {
+ r = in4_addr_default_prefixlen(&buffer.in, &k);
+ if (r < 0)
+ return r;
+ } else
+ k = 0;
} else
k = FAMILY_ADDRESS_SIZE(family) * 8;