diff --git a/src/basic/socket-util.c b/src/basic/socket-util.c index 8402e79c312..552ec053ffe 100644 --- a/src/basic/socket-util.c +++ b/src/basic/socket-util.c @@ -787,7 +787,10 @@ bool ifname_valid_full(const char *p, IfnameValidFlags flags) { if ((unsigned char) *t <= 32U) return false; - if (IN_SET(*t, ':', '/')) + if (IN_SET(*t, + ':', /* colons are used by the legacy "alias" interface logic */ + '/', /* slashes cannot work, since we need to use network interfaces in sysfs paths, and in paths slashes are separators */ + '%')) /* %d is used in the kernel's weird foo%d format string naming feature which we really really don't want to ever run into by accident */ return false; numeric = numeric && (*t >= '0' && *t <= '9'); diff --git a/src/test/test-socket-netlink.c b/src/test/test-socket-netlink.c index af3ccec166f..da484a40032 100644 --- a/src/test/test-socket-netlink.c +++ b/src/test/test-socket-netlink.c @@ -74,7 +74,7 @@ static void test_socket_address_parse(void) { test_socket_address_parse_one("[::1]:1234%lo", 0, AF_INET6, NULL); test_socket_address_parse_one("[::1]:0%lo", -EINVAL, 0, NULL); test_socket_address_parse_one("[::1]%lo", -EINVAL, 0, NULL); - test_socket_address_parse_one("[::1]:1234%lo%lo", -ENODEV, 0, NULL); + test_socket_address_parse_one("[::1]:1234%lo%lo", -EINVAL, 0, NULL); test_socket_address_parse_one("[::1]:1234%xxxxasdf", -ENODEV, 0, NULL); test_socket_address_parse_one("192.168.1.254:8888", 0, AF_INET, NULL); test_socket_address_parse_one("/foo/bar", 0, AF_UNIX, NULL);