From: Roy Marples Date: Wed, 5 Feb 2014 18:32:13 +0000 (+0000) Subject: Fix opening the control socket. X-Git-Tag: v6.3.0~42 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9ab91ddc2041deb8ff5bf8d91a2bc82b981c60ea;p=thirdparty%2Fdhcpcd.git Fix opening the control socket. --- diff --git a/control.c b/control.c index b1a46a0a..dffcf871 100644 --- a/control.c +++ b/control.c @@ -41,6 +41,12 @@ #include "control.h" #include "eloop.h" +#ifndef SUN_LEN +#define SUN_LEN(su) \ + (sizeof(*(su)) - sizeof((su)->sun_path) + strlen((su)->sun_path)) +#endif + + struct fd_list *control_fds = NULL; static void @@ -126,7 +132,7 @@ make_sock(struct control_ctx *ctx, struct sockaddr_un *sun) memset(sun, 0, sizeof(*sun)); sun->sun_family = AF_UNIX; strlcpy(sun->sun_path, CONTROLSOCKET, sizeof(sun->sun_path)); - return sizeof(sun->sun_family) + sizeof(sun->sun_path) + 1; + return SUN_LEN(sun); } int @@ -146,6 +152,7 @@ control_start(struct control_ctx *ctx) listen(ctx->fd, sizeof(control_fds)) == -1) { close(ctx->fd); + ctx->fd = -1; return -1; } eloop_event_add(ctx->fd, control_handle, ctx);