summaryrefslogtreecommitdiff
path: root/src/libwpactrl/wpactrl_start.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libwpactrl/wpactrl_start.c')
-rw-r--r--src/libwpactrl/wpactrl_start.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/libwpactrl/wpactrl_start.c b/src/libwpactrl/wpactrl_start.c
index a3e5331..df2b480 100644
--- a/src/libwpactrl/wpactrl_start.c
+++ b/src/libwpactrl/wpactrl_start.c
@@ -18,14 +18,13 @@ int wpactrl_start (wpactrl_t *a, char const *path, unsigned int timeout, tain_t
{
tain_t tto, deadline ;
int fda, fds ;
- size_t pos ;
stralloc sa = STRALLOC_ZERO ;
if (timeout) tain_from_millisecs(&tto, timeout) ;
else tto = tain_infinite_relative ;
if (!stralloc_cats(&sa, BCNM_TMPDIR)) return 0 ;
- if (!stralloc_cats(&sa, "/clientfds")) goto err ;
- pos = sa.len - 1 ;
- if (!sauniquename(&sa) || !stralloc_0(&sa)) goto err ;
+ if (!stralloc_cats(&sa, "/libwpactrl")
+ || !sauniquename(&sa)
+ || !stralloc_catb(&sa, ":s", 3)) goto err ;
fds = ipc_datagram_nbcoe() ;
if (fds < 0) goto err ;
unlink_void(sa.s) ;
@@ -34,7 +33,7 @@ int wpactrl_start (wpactrl_t *a, char const *path, unsigned int timeout, tain_t
|| !ipc_timed_connect(fds, path, &deadline, stamp)) goto errs ;
fda = ipc_datagram_nbcoe() ;
if (fda < 0) goto errs ;
- sa.s[pos] = 'a' ;
+ sa.s[sa.len - 2] = 'a' ;
unlink_void(sa.s) ;
if (ipc_bind(fda, sa.s) == -1
|| !ipc_timed_connect(fda, path, &deadline, stamp)
@@ -45,7 +44,9 @@ int wpactrl_start (wpactrl_t *a, char const *path, unsigned int timeout, tain_t
r = wpactrl_fd_timed_recv(fda, answer, 3, &deadline, stamp) ;
if (r != 3 || memcmp(answer, "OK\n", 3)) goto erra ;
}
- stralloc_free(&sa) ;
+ if (!stralloc_shrink(&sa)) goto erra ;
+
+ a->clientpath = sa ;
a->fds = fds ;
a->fda = fda ;
a->tto = tto ;