From: Roy Marples Date: Mon, 5 Sep 2016 22:27:47 +0000 (+0000) Subject: recvmsg expects an array of iovec structures, not a pointer to the first one. X-Git-Tag: v6.11.4~43 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=902f2f0071f0f0b47b95c91d03273474cdf2390e;p=thirdparty%2Fdhcpcd.git recvmsg expects an array of iovec structures, not a pointer to the first one. --- diff --git a/dhcpcd.c b/dhcpcd.c index a33e67f6..d9f3e13e 100644 --- a/dhcpcd.c +++ b/dhcpcd.c @@ -1970,7 +1970,7 @@ exit1: if (control_stop(&ctx) == -1) logger(&ctx, LOG_ERR, "control_stop: %m:"); eloop_free(ctx.eloop); - free(ctx.iov.iov_base); + free(ctx.iov[0].iov_base); if (ctx.options & DHCPCD_STARTED && !(ctx.options & DHCPCD_FORKED)) logger(&ctx, LOG_INFO, PACKAGE " exited"); diff --git a/dhcpcd.h b/dhcpcd.h index 7d8244f7..a41360d1 100644 --- a/dhcpcd.h +++ b/dhcpcd.h @@ -121,7 +121,7 @@ struct dhcpcd_ctx { int link_fd; int seq; /* route message sequence no */ int sseq; /* successful seq no sent */ - struct iovec iov; /* generic iovec buffer */ + struct iovec iov[1]; /* generic iovec buffer */ #ifdef USE_SIGNALS sigset_t sigset; diff --git a/if-bsd.c b/if-bsd.c index 6276508a..26f5c3a8 100644 --- a/if-bsd.c +++ b/if-bsd.c @@ -1548,12 +1548,12 @@ if_handlelink(struct dhcpcd_ctx *ctx) ssize_t bytes; memset(&msg, 0, sizeof(msg)); - msg.msg_iov = &ctx->iov; + msg.msg_iov = ctx->iov; msg.msg_iovlen = 1; if ((bytes = recvmsg_realloc(ctx->link_fd, &msg, 0)) == -1) return -1; - if_dispatch(ctx, ctx->iov.iov_base); + if_dispatch(ctx, ctx->iov[0].iov_base); return 0; } diff --git a/if-linux.c b/if-linux.c index 3b49fd6a..564d0bac 100644 --- a/if-linux.c +++ b/if-linux.c @@ -94,7 +94,7 @@ int if_getssid_wext(const char *ifname, uint8_t *ssid); struct priv { int route_fd; uint32_t route_pid; - struct iovec link_iov; + struct iovec link_iov[1]; }; /* Broadcast address for IPoIB */ @@ -300,8 +300,6 @@ if_opensockets_os(struct dhcpcd_ctx *ctx) if (getsockname(priv->route_fd, (struct sockaddr *)&snl, &len) == -1) return -1; priv->route_pid = snl.nl_pid; - priv->link_iov.iov_base = NULL; - priv->link_iov.iov_len = 0; return 0; } @@ -312,7 +310,7 @@ if_closesockets_os(struct dhcpcd_ctx *ctx) if (ctx->priv != NULL) { priv = (struct priv *)ctx->priv; - free(priv->link_iov.iov_base); + free(priv->link_iov[0].iov_base); close(priv->route_fd); } } @@ -859,7 +857,7 @@ if_handlelink(struct dhcpcd_ctx *ctx) struct priv *priv; priv = (struct priv *)ctx->priv; - return get_netlink(ctx, &priv->link_iov, NULL, + return get_netlink(ctx, priv->link_iov, NULL, ctx->link_fd, MSG_DONTWAIT, &link_netlink); } @@ -899,7 +897,7 @@ send_netlink(struct dhcpcd_ctx *ctx, struct interface *ifp, hdr->nlmsg_seq = (uint32_t)++ctx->seq; if (sendmsg(s, &msg, 0) != -1) { ctx->sseq = ctx->seq; - r = get_netlink(ctx, &ctx->iov, ifp, s, 0, callback); + r = get_netlink(ctx, ctx->iov, ifp, s, 0, callback); } else r = -1; if (protocol != NETLINK_ROUTE) diff --git a/if-sun.c b/if-sun.c index 8ce1887b..50897b28 100644 --- a/if-sun.c +++ b/if-sun.c @@ -773,12 +773,12 @@ if_handlelink(struct dhcpcd_ctx *ctx) ssize_t bytes; memset(&msg, 0, sizeof(msg)); - msg.msg_iov = &ctx->iov; + msg.msg_iov = ctx->iov; msg.msg_iovlen = 1; if ((bytes = recvmsg_realloc(ctx->link_fd, &msg, 0)) == -1) return -1; - if_dispatch(ctx, ctx->iov.iov_base); + if_dispatch(ctx, ctx->iov[0].iov_base); return 0; }