]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
More iovec array fixes.
authorRoy Marples <roy@marples.name>
Mon, 5 Sep 2016 22:48:08 +0000 (22:48 +0000)
committerRoy Marples <roy@marples.name>
Mon, 5 Sep 2016 22:48:08 +0000 (22:48 +0000)
if-linux.c

index 564d0baceb56db404d1f04deb1c61d69390f88e5..75b3f434ac47a3a3ad5b939fc78da4d58afff1b3 100644 (file)
@@ -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[1];
+       struct iovec sndrcv_iov[1];
 };
 
 /* Broadcast address for IPoIB */
@@ -310,7 +310,7 @@ if_closesockets_os(struct dhcpcd_ctx *ctx)
 
        if (ctx->priv != NULL) {
                priv = (struct priv *)ctx->priv;
-               free(priv->link_iov[0].iov_base);
+               free(priv->sndrcv_iov[0].iov_base);
                close(priv->route_fd);
        }
 }
@@ -854,10 +854,8 @@ link_netlink(struct dhcpcd_ctx *ctx, struct interface *ifp,
 int
 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, ctx->iov, NULL,
            ctx->link_fd, MSG_DONTWAIT, &link_netlink);
 }
 
@@ -868,7 +866,7 @@ send_netlink(struct dhcpcd_ctx *ctx, struct interface *ifp,
 {
        int s, r;
        struct sockaddr_nl snl;
-       struct iovec iov;
+       struct iovec iov[1];
        struct msghdr msg;
 
        memset(&snl, 0, sizeof(snl));
@@ -888,16 +886,19 @@ send_netlink(struct dhcpcd_ctx *ctx, struct interface *ifp,
        msg.msg_name = &snl;
        msg.msg_namelen = sizeof(snl);
        memset(&iov, 0, sizeof(iov));
-       iov.iov_base = hdr;
-       iov.iov_len = hdr->nlmsg_len;
-       msg.msg_iov = &iov;
+       iov[0].iov_base = hdr;
+       iov[0].iov_len = hdr->nlmsg_len;
+       msg.msg_iov = iov;
        msg.msg_iovlen = 1;
        /* Request a reply */
        hdr->nlmsg_flags |= NLM_F_ACK;
        hdr->nlmsg_seq = (uint32_t)++ctx->seq;
        if (sendmsg(s, &msg, 0) != -1) {
+               struct priv *priv;
+
+               priv = (struct priv *)ctx->priv;
                ctx->sseq = ctx->seq;
-               r = get_netlink(ctx, ctx->iov, ifp, s, 0, callback);
+               r = get_netlink(ctx, priv->sndrcv_iov, ifp, s, 0, callback);
        } else
                r = -1;
        if (protocol != NETLINK_ROUTE)