summaryrefslogtreecommitdiffstats
path: root/src/nspawn
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2023-08-23 05:13:44 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2023-08-24 15:55:32 +0200
commit927e20fa4976c7b68c95814f3706cd4e89ac28c8 (patch)
tree6763cf1b3546534f9e2b5f0153abbf0a8d47a0dc /src/nspawn
parentman/repart: use <filename> and add missing <para> (diff)
downloadsystemd-927e20fa4976c7b68c95814f3706cd4e89ac28c8.tar.xz
systemd-927e20fa4976c7b68c95814f3706cd4e89ac28c8.zip
nspawn: check validity of the internal interface name only explicitly specified
Follow-up for 2f091b1b49543aade4aad9ec3b35b3665abac3e7. Fixes #28844.
Diffstat (limited to 'src/nspawn')
-rw-r--r--src/nspawn/nspawn-network.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/nspawn/nspawn-network.c b/src/nspawn/nspawn-network.c
index 89b50026db..b83e472245 100644
--- a/src/nspawn/nspawn-network.c
+++ b/src/nspawn/nspawn-network.c
@@ -774,20 +774,22 @@ static int network_iface_pair_parse(const char* iftype, char ***l, const char *p
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"%s, interface name not valid: %s", iftype, a);
- if (isempty(interface)) {
- if (ifprefix)
- b = strjoin(ifprefix, a);
- else
- b = strdup(a);
- } else
+ /* Here, we only check the validity of the specified second name. If it is not specified,
+ * the copied or prefixed name should be already valid, except for its length. If it is too
+ * long, then it will be shortened later. */
+ if (!isempty(interface)) {
+ if (!ifname_valid(interface))
+ return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+ "%s, interface name not valid: %s", iftype, interface);
+
b = strdup(interface);
+ } else if (ifprefix)
+ b = strjoin(ifprefix, a);
+ else
+ b = strdup(a);
if (!b)
return log_oom();
- if (!ifname_valid(b))
- return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
- "%s, interface name not valid: %s", iftype, b);
-
r = strv_consume_pair(l, TAKE_PTR(a), TAKE_PTR(b));
if (r < 0)
return log_oom();