e = bus_address_escape(t);
if (!e)
return -ENOMEM;
- } else if ((a = strchr(host, '@')))
+ } else if ((a = strchr(host, '@'))) {
if (*(a + 1) == '[') {
_cleanup_free_ char *t = NULL;
e = bus_address_escape(t);
if (!e)
return -ENOMEM;
- }
+ } else if (*(a + 1) == '\0' || strchr(a + 1, '@'))
+ return -EINVAL;
+ }
/* Let's see if a port was given */
m = strchr(rbracket ? rbracket + 1 : host, ':');
got_forward_slash = true;
}
- if (!in_charset(p, "0123456789")) {
+ if (!in_charset(p, "0123456789") || *p == '\0') {
if (!machine_name_is_valid(p) || got_forward_slash)
return -EINVAL;
else {
0, "unixexec:path=ssh,argv1=-xT,argv2=-p,argv3=123,argv4=--,argv5=host,argv6=systemd-stdio-bridge");
test_one_address(b, "host:123:123",
-EINVAL, NULL);
- // test_one_address(b, "host:",
- // -EINVAL, NULL);
+ test_one_address(b, "host:",
+ -EINVAL, NULL);
test_one_address(b, "user@host",
0, "unixexec:path=ssh,argv1=-xT,argv2=--,argv3=user%40host,argv4=systemd-stdio-bridge");
- // test_one_address(b, "user@host@host",
- // -EINVAL, NULL);
+ test_one_address(b, "user@host@host",
+ -EINVAL, NULL);
test_one_address(b, "[::1]",
0, "unixexec:path=ssh,argv1=-xT,argv2=--,argv3=%3a%3a1,argv4=systemd-stdio-bridge");
test_one_address(b, "user@[::1]",
0, "unixexec:path=ssh,argv1=-xT,argv2=--,argv3=user%40%3a%3a1,argv4=systemd-stdio-bridge");
test_one_address(b, "user@[::1]:99",
0, "unixexec:path=ssh,argv1=-xT,argv2=-p,argv3=99,argv4=--,argv5=user%40%3a%3a1,argv6=systemd-stdio-bridge");
- //test_one_address(b, "user@[::1]:",
- // -EINVAL, NULL);
+ test_one_address(b, "user@[::1]:",
+ -EINVAL, NULL);
test_one_address(b, "user@[::1:",
-EINVAL, NULL);
- //test_one_address(b, "user@",
- // -EINVAL, NULL);
- //test_one_address(b, "user@@",
- // -EINVAL, NULL);
+ test_one_address(b, "user@",
+ -EINVAL, NULL);
+ test_one_address(b, "user@@",
+ -EINVAL, NULL);
}
int main(int argc, char *argv[]) {