Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/bsd/dhcpcd/dist Import dhcpcd-6.3.1 with the follow...



details:   https://anonhg.NetBSD.org/src/rev/0bb6d9cd219d
branches:  trunk
changeset: 793926:0bb6d9cd219d
user:      roy <roy%NetBSD.org@localhost>
date:      Sat Mar 01 11:00:41 2014 +0000

description:
Import dhcpcd-6.3.1 with the following changes

  * all issuses reported by clang static analyser have been resolved.

diffstat:

 external/bsd/dhcpcd/dist/auth.c                         |  10 +-
 external/bsd/dhcpcd/dist/defs.h                         |   4 +-
 external/bsd/dhcpcd/dist/dev.h                          |   6 +-
 external/bsd/dhcpcd/dist/dhcp-common.c                  |  23 ++--
 external/bsd/dhcpcd/dist/dhcp6.c                        |  85 +++++++++-------
 external/bsd/dhcpcd/dist/dhcpcd-hooks/01-test           |   5 +-
 external/bsd/dhcpcd/dist/dhcpcd-hooks/10-wpa_supplicant |  14 +-
 7 files changed, 81 insertions(+), 66 deletions(-)

diffs (truncated from 389 to 300 lines):

diff -r a0d2686fd86d -r 0bb6d9cd219d external/bsd/dhcpcd/dist/auth.c
--- a/external/bsd/dhcpcd/dist/auth.c   Sat Mar 01 10:28:02 2014 +0000
+++ b/external/bsd/dhcpcd/dist/auth.c   Sat Mar 01 11:00:41 2014 +0000
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: auth.c,v 1.1.1.1 2014/02/25 13:14:30 roy Exp $");
+ __RCSID("$NetBSD: auth.c,v 1.1.1.2 2014/03/01 11:00:43 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -346,18 +346,20 @@
                        } else {
                                free(state->token);
                                state->token = NULL;
+                               return NULL;
                        }
-                       if (t->realm) {
+                       if (t->realm_len) {
                                state->token->realm = malloc(t->realm_len);
                                if (state->token->realm) {
                                        state->token->realm_len = t->realm_len;
                                        memcpy(state->token->realm, t->realm,
                                            t->realm_len);
-                           } else {
+                               } else {
                                        free(state->token->key);
                                        free(state->token);
                                        state->token = NULL;
-                           }
+                                       return NULL;
+                               }
                        } else {
                                state->token->realm = NULL;
                                state->token->realm_len = 0;
diff -r a0d2686fd86d -r 0bb6d9cd219d external/bsd/dhcpcd/dist/defs.h
--- a/external/bsd/dhcpcd/dist/defs.h   Sat Mar 01 10:28:02 2014 +0000
+++ b/external/bsd/dhcpcd/dist/defs.h   Sat Mar 01 11:00:41 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: defs.h,v 1.1.1.35 2014/02/25 13:14:30 roy Exp $ */
+/* $NetBSD: defs.h,v 1.1.1.36 2014/03/01 11:00:43 roy Exp $ */
 
 /*
  * dhcpcd - DHCP client daemon
@@ -30,7 +30,7 @@
 #define CONFIG_H
 
 #define PACKAGE                        "dhcpcd"
-#define VERSION                        "6.3.0"
+#define VERSION                        "6.3.1"
 
 #ifndef CONFIG
 # define CONFIG                        SYSCONFDIR "/" PACKAGE ".conf"
diff -r a0d2686fd86d -r 0bb6d9cd219d external/bsd/dhcpcd/dist/dev.h
--- a/external/bsd/dhcpcd/dist/dev.h    Sat Mar 01 10:28:02 2014 +0000
+++ b/external/bsd/dhcpcd/dist/dev.h    Sat Mar 01 11:00:41 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dev.h,v 1.1.1.2 2014/02/25 13:14:30 roy Exp $ */
+/* $NetBSD: dev.h,v 1.1.1.3 2014/03/01 11:00:43 roy Exp $ */
 
 /*
  * dhcpcd - DHCP client daemon
@@ -53,8 +53,8 @@
 int dev_start(struct dhcpcd_ctx *);
 void dev_stop(struct dhcpcd_ctx *, int);
 #else
-#define dev_initialized(a, b) 1
-#define dev_listening(a) 0
+#define dev_initialized(a, b) (1)
+#define dev_listening(a) (0)
 #define dev_start(a) {}
 #define dev_stop(a, b) {}
 #endif
diff -r a0d2686fd86d -r 0bb6d9cd219d external/bsd/dhcpcd/dist/dhcp-common.c
--- a/external/bsd/dhcpcd/dist/dhcp-common.c    Sat Mar 01 10:28:02 2014 +0000
+++ b/external/bsd/dhcpcd/dist/dhcp-common.c    Sat Mar 01 11:00:41 2014 +0000
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: dhcp-common.c,v 1.1.1.4 2014/02/25 13:14:29 roy Exp $");
+ __RCSID("$NetBSD: dhcp-common.c,v 1.1.1.5 2014/03/01 11:00:41 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -47,19 +47,19 @@
 struct dhcp_opt *
 vivso_find(uint16_t iana_en, const void *arg)
 {
-       const struct interface *ifp = arg;
+       const struct interface *ifp;
        size_t i;
        struct dhcp_opt *opt;
 
-       if (arg) {
-               ifp = arg;
-               for (i = 0, opt = ifp->options->vivso_override;
-                   i < ifp->options->vivso_override_len;
-                   i++, opt++)
-                       if (opt->option == iana_en)
-                               return opt;
-       }
-       for (i = 0, opt = ifp->ctx->vivso; i < ifp->ctx->vivso_len; i++, opt++)
+       ifp = arg;
+       for (i = 0, opt = ifp->options->vivso_override;
+           i < ifp->options->vivso_override_len;
+           i++, opt++)
+               if (opt->option == iana_en)
+                       return opt;
+       for (i = 0, opt = ifp->ctx->vivso;
+           i < ifp->ctx->vivso_len;
+           i++, opt++)
                if (opt->option == iana_en)
                        return opt;
        return NULL;
@@ -355,7 +355,6 @@
                return dl - (dl % ADDR6SZ);
        }
 
-       sz = 0;
        if (opt->type & (UINT32 | ADDRIPV4))
                sz = sizeof(uint32_t);
        else if (opt->type & UINT16)
diff -r a0d2686fd86d -r 0bb6d9cd219d external/bsd/dhcpcd/dist/dhcp6.c
--- a/external/bsd/dhcpcd/dist/dhcp6.c  Sat Mar 01 10:28:02 2014 +0000
+++ b/external/bsd/dhcpcd/dist/dhcp6.c  Sat Mar 01 11:00:41 2014 +0000
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: dhcp6.c,v 1.1.1.7 2014/02/25 13:14:30 roy Exp $");
+ __RCSID("$NetBSD: dhcp6.c,v 1.1.1.8 2014/03/01 11:00:43 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -838,6 +838,8 @@
 
        /* Set the outbound interface */
        cm = CMSG_FIRSTHDR(&ctx->sndhdr);
+       if (cm == NULL) /* unlikely */
+               return -1;
        cm->cmsg_level = IPPROTO_IPV6;
        cm->cmsg_type = IPV6_PKTINFO;
        cm->cmsg_len = CMSG_LEN(sizeof(pi));
@@ -1209,7 +1211,8 @@
                syslog(LOG_ERR, "%s: %m", __func__);
                return -1;
        }
-       memcpy(status, p, len);
+       if (p)
+               memcpy(status, p, len);
        status[len] = '\0';
        syslog(LOG_ERR, "%s: DHCPv6 REPLY: %s", ifp->name, status);
        free(status);
@@ -1356,7 +1359,9 @@
                            iabuf, sizeof(iabuf));
                        snprintf(a->saddr, sizeof(a->saddr),
                            "%s/%d", ia, a->prefix_len);
-               }
+                       TAILQ_INSERT_TAIL(&state->addrs, a, next);
+               } else
+                       a->flags &= ~IPV6_AF_STALE;
                memcpy(&u32, p, sizeof(u32));
                a->prefix_pltime = ntohl(u32);
                p += sizeof(u32);
@@ -1370,10 +1375,6 @@
                    state->lowpl = a->prefix_pltime;
                if (a->prefix_vltime && a->prefix_vltime > state->expire)
                    state->expire = a->prefix_vltime;
-               if (a->flags & IPV6_AF_STALE)
-                       a->flags &= ~IPV6_AF_STALE;
-               else
-                       TAILQ_INSERT_TAIL(&state->addrs, a, next);
                i++;
        }
        return i;
@@ -1419,7 +1420,6 @@
                p += sizeof(u8);
                len = u8;
                memcpy(&prefix.s6_addr, p, sizeof(prefix.s6_addr));
-               p += sizeof(prefix.s6_addr);
 
                TAILQ_FOREACH(a, &state->addrs, next) {
                        if (IN6_ARE_ADDR_EQUAL(&a->prefix, &prefix))
@@ -1442,8 +1442,12 @@
                            iabuf, sizeof(iabuf));
                        snprintf(a->saddr, sizeof(a->saddr),
                            "%s/%d", ia, a->prefix_len);
-               } else if (a->prefix_vltime != vltime)
-                       a->flags |= IPV6_AF_NEW;
+                       TAILQ_INSERT_TAIL(&state->addrs, a, next);
+               } else {
+                       a->flags &= ~IPV6_AF_STALE;
+                       if (a->prefix_vltime != vltime)
+                               a->flags |= IPV6_AF_NEW;
+               }
 
                a->prefix_pltime = pltime;
                a->prefix_vltime = vltime;
@@ -1451,10 +1455,6 @@
                        state->lowpl = a->prefix_pltime;
                if (a->prefix_vltime && a->prefix_vltime > state->expire)
                        state->expire = a->prefix_vltime;
-               if (a->flags & IPV6_AF_STALE)
-                       a->flags &= ~IPV6_AF_STALE;
-               else
-                       TAILQ_INSERT_TAIL(&state->addrs, a, next);
                i++;
        }
        return i;
@@ -1506,6 +1506,26 @@
                        rebind = ntohl(u32);
                        p += sizeof(u32);
                        ol -= sizeof(u32);
+               } else
+                       renew = rebind = 0; /* appease gcc */
+               if (dhcp6_checkstatusok(ifp, NULL, p, ol) == -1)
+                       continue;
+               if (ifo->ia_type == D6_OPTION_IA_PD) {
+                       if (dhcp6_findpd(ifp, iaid, p, ol) == 0) {
+                               syslog(LOG_WARNING,
+                                   "%s: %s: DHCPv6 REPLY missing Prefix",
+                                   ifp->name, sfrom);
+                               continue;
+                       }
+               } else {
+                       if (dhcp6_findna(ifp, iaid, p, ol) == 0) {
+                               syslog(LOG_WARNING,
+                                   "%s: %s: DHCPv6 REPLY missing IA Address",
+                                   ifp->name, sfrom);
+                               continue;
+                       }
+               }
+               if (ifo->ia_type != D6_OPTION_IA_TA) {
                        if (renew > rebind && rebind > 0) {
                                if (sfrom)
                                    syslog(LOG_WARNING,
@@ -1521,23 +1541,6 @@
                            (rebind < state->rebind || state->rebind == 0))
                                state->rebind = rebind;
                }
-               if (dhcp6_checkstatusok(ifp, NULL, p, ol) == -1)
-                       return -1;
-               if (ifo->ia_type == D6_OPTION_IA_PD) {
-                       if (dhcp6_findpd(ifp, iaid, p, ol) == 0) {
-                               syslog(LOG_ERR,
-                                   "%s: %s: DHCPv6 REPLY missing Prefix",
-                                   ifp->name, sfrom);
-                               return -1;
-                       }
-               } else {
-                       if (dhcp6_findna(ifp, iaid, p, ol) == 0) {
-                               syslog(LOG_ERR,
-                                   "%s: %s: DHCPv6 REPLY missing IA Address",
-                                   ifp->name, sfrom);
-                               return -1;
-                       }
-               }
                i++;
        }
        TAILQ_FOREACH_SAFE(ap, &state->addrs, next, nap) {
@@ -2633,9 +2636,14 @@
 {
        struct dhcp6_state *state;
        struct dhcpcd_ctx *ctx;
+       int options;
 
        eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp);
 
+       if (ifp->options)
+               options = ifp->options->options;
+       else
+               options = 0;
        /*
         * As the interface is going away from dhcpcd we need to
         * remove the delegated addresses, otherwise we lose track
@@ -2644,30 +2652,31 @@
         * how we remember which interface delegated.
         *
         * XXX The below is no longer true due to the change of the
-        * default IAID, but do PPP links have stable ethernet addresses?
+        * default IAID, but do PPP links have stable ethernet
+        * addresses?
         *
         * To make it more interesting, on some OS's with PPP links
         * there is no guarantee the delegating interface will have
         * the same name or index so think very hard before changing
         * this.
         */
-       if (ifp->options &&
-           ifp->options->options & (DHCPCD_STOPPING | DHCPCD_RELEASE) &&
-           (ifp->options->options & (DHCPCD_EXITING | DHCPCD_PERSISTENT)) !=
+       if (options & (DHCPCD_STOPPING | DHCPCD_RELEASE) &&
+           (options &
+           (DHCPCD_EXITING | DHCPCD_PERSISTENT)) !=
            (DHCPCD_EXITING | DHCPCD_PERSISTENT))
                dhcp6_delete_delegates(ifp);
 
        state = D6_STATE(ifp);
        if (state) {
                dhcp_auth_reset(&state->auth);
-               if (ifp->options->options & DHCPCD_RELEASE) {
+               if (options & DHCPCD_RELEASE) {
                        if (ifp->carrier != LINK_DOWN)
                                dhcp6_startrelease(ifp);



Home | Main Index | Thread Index | Old Index