abduco

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | LICENSE

commit 6a99af6d1e23c588c1ed66600f95ea3ce408d09e
parent 3a14718bb76a9fb8e730c4423562b34ab6d9da81
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Fri,  7 Mar 2014 18:57:37 +0100

Fix support for relative socket paths

The server is invoking chdir("/") thus the relative paths became
meaningless.

Maybe realpath(3) with NULL as second argument should be used instead.

Diffstat:
abduco.c | 9++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/abduco.c b/abduco.c @@ -198,10 +198,17 @@ static int create_socket_dir() { static int create_socket(const char *name) { size_t maxlen = sizeof(sockaddr.sun_path); - if (name[0] == '.' || name[0] == '/') { + if (name[0] == '/') { strncpy(sockaddr.sun_path, name, maxlen); if (sockaddr.sun_path[maxlen-1]) return -1; + } else if (name[0] == '.') { + char buf[maxlen], *cwd = getcwd(buf, sizeof buf); + if (!cwd) + return -1; + int len = snprintf(sockaddr.sun_path, maxlen, "%s/%s", cwd, name); + if (len < 0 || (size_t)len >= maxlen) + return -1; } else { int len = create_socket_dir(), rem = strlen(name); if (len == -1 || maxlen - len - rem <= 0)