]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Ensure we close the contol socket if we fail to connect.
authorRoy Marples <roy@marples.name>
Wed, 12 Feb 2014 20:51:57 +0000 (20:51 +0000)
committerRoy Marples <roy@marples.name>
Wed, 12 Feb 2014 20:51:57 +0000 (20:51 +0000)
Don't crash when closing IPv6ND or DHCPv6 when not the IPv6 protocol is
not started.

control.c
dhcp6.c
dhcpcd.c
ipv6nd.c

index 6e47d63afde701eeb9d50bca1ed1966bf9e3367c..14d07b2c9ff561b882160d3823e3c5d6375eb445 100644 (file)
--- a/control.c
+++ b/control.c
@@ -197,7 +197,12 @@ control_open(struct dhcpcd_ctx *ctx)
 
        if ((len = make_sock(ctx, &sun)) == -1)
                return -1;
-       return connect(ctx->control_fd, (struct sockaddr *)&sun, len);
+       if (connect(ctx->control_fd, (struct sockaddr *)&sun, len) == -1) {
+               close(ctx->control_fd);
+               ctx->control_fd = -1;
+               return -1;
+       }
+       return 0;
 }
 
 int
diff --git a/dhcp6.c b/dhcp6.c
index 6dcd5ef3ee2e626ad31b795e7793ec62cce92019..57add6aff7a060ca96ca6b23e3abecc90ae8a578 100644 (file)
--- a/dhcp6.c
+++ b/dhcp6.c
@@ -2670,7 +2670,7 @@ dhcp6_freedrop(struct interface *ifp, int drop, const char *reason)
                                break;
                }
        }
-       if (ifp == NULL) {
+       if (ifp == NULL && ctx->ipv6) {
                if (ctx->ipv6->dhcp_fd != -1) {
                        eloop_event_delete(ctx->eloop, ctx->ipv6->dhcp_fd);
                        close(ctx->ipv6->dhcp_fd);
index e8d413f13060b2267bc3527488f983ec970790bc..714974c281aba32da09c529eadac1f7d661ba9d0 100644 (file)
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -1503,5 +1503,6 @@ exit1:
 
        if (ctx.options & DHCPCD_STARTED && !(ctx.options & DHCPCD_FORKED))
                syslog(LOG_INFO, "exited");
+       closelog();
        return i;
 }
index 8b8f52fa35996d85ae4fb1de5b9a0f0953c6ede7..acc2699fe509e0b16f9fb5b86d1100f4a6b2497f 100644 (file)
--- a/ipv6nd.c
+++ b/ipv6nd.c
@@ -999,9 +999,11 @@ ipv6nd_has_ra(const struct interface *ifp)
 {
        const struct ra *rap;
 
-       TAILQ_FOREACH(rap, ifp->ctx->ipv6->ra_routers, next)
-               if (rap->iface == ifp)
-                       return 1;
+       if (ifp->ctx->ipv6) {
+               TAILQ_FOREACH(rap, ifp->ctx->ipv6->ra_routers, next)
+                       if (rap->iface == ifp)
+                               return 1;
+       }
        return 0;
 }
 
@@ -1227,6 +1229,9 @@ ipv6nd_drop(struct interface *ifp)
        int expired = 0;
        TAILQ_HEAD(rahead, ra) rtrs;
 
+       if (ifp->ctx->ipv6 == NULL)
+               return;
+
        eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp);
        TAILQ_INIT(&rtrs);
        TAILQ_FOREACH(rap, ifp->ctx->ipv6->ra_routers, next) {