diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-10-15 13:58:31 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2018-10-15 19:40:51 +0200 |
commit | 15a3e96f9220c931507456764902ff05d7171318 (patch) | |
tree | cd669f3363875fe1ee98a4bbcd77f1c27ca30f5e /src/socket-proxy | |
parent | 5cf91ea9c858fca03983c96932c886497953603e (diff) | |
download | systemd-15a3e96f9220c931507456764902ff05d7171318.tar.gz |
tree-wide: port various users over to sockaddr_un_set_path()
CID 1396140
CID 1396141
Diffstat (limited to 'src/socket-proxy')
-rw-r--r-- | src/socket-proxy/socket-proxyd.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/socket-proxy/socket-proxyd.c b/src/socket-proxy/socket-proxyd.c index 4c60d97c39..227378edaa 100644 --- a/src/socket-proxy/socket-proxyd.c +++ b/src/socket-proxy/socket-proxyd.c @@ -378,17 +378,16 @@ static int resolve_remote(Connection *c) { const char *node, *service; int r; - if (path_is_absolute(arg_remote_host)) { - sa.un.sun_family = AF_UNIX; - strncpy(sa.un.sun_path, arg_remote_host, sizeof(sa.un.sun_path)); - return connection_start(c, &sa.sa, SOCKADDR_UN_LEN(sa.un)); - } + if (IN_SET(arg_remote_host[0], '/', '@')) { + int salen; + + salen = sockaddr_un_set_path(&sa.un, arg_remote_host); + if (salen < 0) { + log_error_errno(salen, "Specified address doesn't fit in an AF_UNIX address, refusing: %m"); + goto fail; + } - if (arg_remote_host[0] == '@') { - sa.un.sun_family = AF_UNIX; - sa.un.sun_path[0] = 0; - strncpy(sa.un.sun_path+1, arg_remote_host+1, sizeof(sa.un.sun_path)-1); - return connection_start(c, &sa.sa, SOCKADDR_UN_LEN(sa.un)); + return connection_start(c, &sa.sa, salen); } service = strrchr(arg_remote_host, ':'); |