Source-Changes-HG archive

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

[src/ROY]: src/external/bsd/dhcpcd/dist/src Import dhcpcd-7.0.3 with the foll...



details:   https://anonhg.NetBSD.org/src/rev/8bf13d36fddf
branches:  ROY
changeset: 455208:8bf13d36fddf
user:      roy <roy%NetBSD.org@localhost>
date:      Fri Apr 06 10:46:37 2018 +0000

description:
Import dhcpcd-7.0.3 with the following changes:

  *  dhcp6: fix a null termination overflow on status messages
  *  options: static routes can be setup in global context again
  *  routes: dhcpcd added host routes are now reported correctly

diffstat:

 external/bsd/dhcpcd/dist/src/defs.h       |   2 +-
 external/bsd/dhcpcd/dist/src/dhcp6.c      |  11 ++++---
 external/bsd/dhcpcd/dist/src/dhcpcd.c     |  24 +++++++++-------
 external/bsd/dhcpcd/dist/src/if-options.c |  27 ++++--------------
 external/bsd/dhcpcd/dist/src/if-options.h |   2 +-
 external/bsd/dhcpcd/dist/src/if.c         |   2 +-
 external/bsd/dhcpcd/dist/src/ipv4.c       |   6 ++-
 external/bsd/dhcpcd/dist/src/route.c      |  44 +++++++++++++++++++++++-------
 external/bsd/dhcpcd/dist/src/route.h      |   3 ++
 9 files changed, 71 insertions(+), 50 deletions(-)

diffs (truncated from 387 to 300 lines):

diff -r 435d0c40ff17 -r 8bf13d36fddf external/bsd/dhcpcd/dist/src/defs.h
--- a/external/bsd/dhcpcd/dist/src/defs.h       Tue Mar 27 06:14:39 2018 +0000
+++ b/external/bsd/dhcpcd/dist/src/defs.h       Fri Apr 06 10:46:37 2018 +0000
@@ -28,7 +28,7 @@
 #define CONFIG_H
 
 #define PACKAGE                        "dhcpcd"
-#define VERSION                        "7.0.2"
+#define VERSION                        "7.0.3"
 
 #ifndef CONFIG
 # define CONFIG                        SYSCONFDIR "/" PACKAGE ".conf"
diff -r 435d0c40ff17 -r 8bf13d36fddf external/bsd/dhcpcd/dist/src/dhcp6.c
--- a/external/bsd/dhcpcd/dist/src/dhcp6.c      Tue Mar 27 06:14:39 2018 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcp6.c      Fri Apr 06 10:46:37 2018 +0000
@@ -1847,6 +1847,7 @@
 {
        uint8_t *opt;
        uint16_t opt_len, code;
+       size_t mlen;
        void * (*f)(void *, size_t, uint16_t, uint16_t *), *farg;
        char buf[32], *sbuf;
        const char *status;
@@ -1872,8 +1873,8 @@
 
        /* Anything after the code is a message. */
        opt += sizeof(code);
-       opt_len = (uint16_t)(opt_len - sizeof(code));
-       if (opt_len == 0) {
+       mlen = opt_len - sizeof(code);
+       if (mlen == 0) {
                sbuf = NULL;
                if (code < sizeof(dhcp6_statuses) / sizeof(char *))
                        status = dhcp6_statuses[code];
@@ -1882,12 +1883,12 @@
                        status = buf;
                }
        } else {
-               if ((sbuf = malloc((size_t)opt_len + 1)) == NULL) {
+               if ((sbuf = malloc(mlen + 1)) == NULL) {
                        logerr(__func__);
                        return -1;
                }
-               memcpy(sbuf, opt, opt_len);
-               sbuf[len] = '\0';
+               memcpy(sbuf, opt, mlen);
+               sbuf[mlen] = '\0';
                status = sbuf;
        }
 
diff -r 435d0c40ff17 -r 8bf13d36fddf external/bsd/dhcpcd/dist/src/dhcpcd.c
--- a/external/bsd/dhcpcd/dist/src/dhcpcd.c     Tue Mar 27 06:14:39 2018 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcpcd.c     Fri Apr 06 10:46:37 2018 +0000
@@ -577,7 +577,7 @@
        } else
                *ifp->profile = '\0';
 
-       free_options(ifp->options);
+       free_options(ifp->ctx, ifp->options);
        ifp->options = ifo;
        if (profile) {
                add_options(ifp->ctx, ifp->name, ifp->options,
@@ -995,6 +995,7 @@
        }
        /* Check if we already have the interface */
        iff = if_find(ctx->ifaces, ifp->name);
+
        if (iff != NULL) {
                if (iff->active)
                        logdebugx("%s: interface updated", iff->name);
@@ -1013,9 +1014,12 @@
                }
                iff = ifp;
        }
-       if_learnaddrs(ctx, ifs, &ifaddrs);
-       if (action > 0 && iff->active)
-               dhcpcd_prestartinterface(iff);
+
+       if (action > 0) {
+               if_learnaddrs(ctx, ifs, &ifaddrs);
+               if (iff->active)
+                       dhcpcd_prestartinterface(iff);
+       }
 
        /* Free our discovered list */
        while ((ifp = TAILQ_FIRST(ifs))) {
@@ -1161,7 +1165,7 @@
        if (ctx->options & DHCPCD_DAEMONISED)
                ifo->options |= DHCPCD_DAEMONISED;
        ctx->options = ifo->options;
-       free_options(ifo);
+       free_options(ctx, ifo);
 }
 
 static void
@@ -1519,6 +1523,8 @@
 #ifdef INET
        ctx.udp_fd = -1;
 #endif
+       rt_init(&ctx);
+
        logopts = LOGERR_ERR|LOGERR_LOG|LOGERR_LOG_DATE|LOGERR_LOG_PID;
        i = 0;
        while ((opt = getopt_long(argc, argv,
@@ -1613,7 +1619,7 @@
        if (i == 2) {
                printf("Interface options:\n");
                if (optind == argc - 1) {
-                       free_options(ifo);
+                       free_options(&ctx, ifo);
                        ifo = read_config(&ctx, argv[optind], NULL, NULL);
                        if (ifo == NULL)
                                goto exit_failure;
@@ -1929,8 +1935,6 @@
                }
        }
 
-       rt_init(&ctx);
-
        TAILQ_FOREACH(ifp, ctx.ifaces, next) {
                if (ifp->active)
                        dhcpcd_initstate1(ifp, argc, argv, 0);
@@ -1981,7 +1985,7 @@
                            handle_exit_timeout, &ctx);
                }
        }
-       free_options(ifo);
+       free_options(&ctx, ifo);
        ifo = NULL;
 
        if_sortinterfaces(&ctx);
@@ -2018,6 +2022,7 @@
                }
                free(ctx.ifaces);
        }
+       free_options(&ctx, ifo);
        rt_dispose(&ctx);
        free(ctx.duid);
        if (ctx.link_fd != -1) {
@@ -2025,7 +2030,6 @@
                close(ctx.link_fd);
        }
        if_closesockets(&ctx);
-       free_options(ifo);
        free_globals(&ctx);
        ipv6_ctxfree(&ctx);
        dev_stop(&ctx);
diff -r 435d0c40ff17 -r 8bf13d36fddf external/bsd/dhcpcd/dist/src/if-options.c
--- a/external/bsd/dhcpcd/dist/src/if-options.c Tue Mar 27 06:14:39 2018 +0000
+++ b/external/bsd/dhcpcd/dist/src/if-options.c Fri Apr 06 10:46:37 2018 +0000
@@ -1086,14 +1086,8 @@
                    strncmp(arg, "ms_classless_static_routes=",
                        strlen("ms_classless_static_routes=")) == 0)
                {
-                       struct interface *ifp;
                        struct in_addr addr3;
 
-                       ifp = if_find(ctx->ifaces, ifname);
-                       if (ifp == NULL) {
-                               logerrx("static routes require an interface");
-                               return -1;
-                       }
                        fp = np = strwhite(p);
                        if (np == NULL) {
                                logerrx("all routes need a gateway");
@@ -1107,7 +1101,7 @@
                                *fp = ' ';
                                return -1;
                        }
-                       if ((rt = rt_new(ifp)) == NULL) {
+                       if ((rt = rt_new0(ctx)) == NULL) {
                                *fp = ' ';
                                return -1;
                        }
@@ -1117,16 +1111,9 @@
                        TAILQ_INSERT_TAIL(&ifo->routes, rt, rt_next);
                        *fp = ' ';
                } else if (strncmp(arg, "routers=", strlen("routers=")) == 0) {
-                       struct interface *ifp;
-
-                       ifp = if_find(ctx->ifaces, ifname);
-                       if (ifp == NULL) {
-                               logerrx("static routes require an interface");
-                               return -1;
-                       }
                        if (parse_addr(&addr, NULL, p) == -1)
                                return -1;
-                       if ((rt = rt_new(ifp)) == NULL)
+                       if ((rt = rt_new0(ctx)) == NULL)
                                return -1;
                        addr2.s_addr = INADDR_ANY;
                        sa_in_init(&rt->rt_dest, &addr2);
@@ -2367,7 +2354,7 @@
                buf = malloc(buflen);
                if (buf == NULL) {
                        logerr(__func__);
-                       free_options(ifo);
+                       free_options(ctx, ifo);
                        return NULL;
                }
                ldop = edop = NULL;
@@ -2381,7 +2368,7 @@
                                if (nbuf == NULL) {
                                        logerr(__func__);
                                        free(buf);
-                                       free_options(ifo);
+                                       free_options(ctx, ifo);
                                        return NULL;
                                }
                                buf = nbuf;
@@ -2545,7 +2532,7 @@
        free(buf);
 
        if (profile && !have_profile) {
-               free_options(ifo);
+               free_options(ctx, ifo);
                errno = ENOENT;
                return NULL;
        }
@@ -2590,7 +2577,7 @@
 }
 
 void
-free_options(struct if_options *ifo)
+free_options(struct dhcpcd_ctx *ctx, struct if_options *ifo)
 {
        size_t i;
        struct dhcp_opt *opt;
@@ -2612,7 +2599,7 @@
                                free(ifo->config[i++]);
                        free(ifo->config);
                }
-               rt_headclear(&ifo->routes, AF_UNSPEC);
+               rt_headclear0(ctx, &ifo->routes, AF_UNSPEC);
                free(ifo->script);
                free(ifo->arping);
                free(ifo->blacklist);
diff -r 435d0c40ff17 -r 8bf13d36fddf external/bsd/dhcpcd/dist/src/if-options.h
--- a/external/bsd/dhcpcd/dist/src/if-options.h Tue Mar 27 06:14:39 2018 +0000
+++ b/external/bsd/dhcpcd/dist/src/if-options.h Fri Apr 06 10:46:37 2018 +0000
@@ -230,6 +230,6 @@
 int add_options(struct dhcpcd_ctx *, const char *,
     struct if_options *, int, char **);
 void free_dhcp_opt_embenc(struct dhcp_opt *);
-void free_options(struct if_options *);
+void free_options(struct dhcpcd_ctx *, struct if_options *);
 
 #endif
diff -r 435d0c40ff17 -r 8bf13d36fddf external/bsd/dhcpcd/dist/src/if.c
--- a/external/bsd/dhcpcd/dist/src/if.c Tue Mar 27 06:14:39 2018 +0000
+++ b/external/bsd/dhcpcd/dist/src/if.c Fri Apr 06 10:46:37 2018 +0000
@@ -85,7 +85,7 @@
        ipv6nd_free(ifp);
        ipv6_free(ifp);
        rt_freeif(ifp);
-       free_options(ifp->options);
+       free_options(ifp->ctx, ifp->options);
        free(ifp);
 }
 
diff -r 435d0c40ff17 -r 8bf13d36fddf external/bsd/dhcpcd/dist/src/ipv4.c
--- a/external/bsd/dhcpcd/dist/src/ipv4.c       Tue Mar 27 06:14:39 2018 +0000
+++ b/external/bsd/dhcpcd/dist/src/ipv4.c       Fri Apr 06 10:46:37 2018 +0000
@@ -289,10 +289,11 @@
                TAILQ_FOREACH(r, &ifp->options->routes, rt_next) {
                        if (sa_is_unspecified(&r->rt_gateway))
                                break;
-                       if ((rt = rt_new(ifp)) == NULL)
+                       if ((rt = rt_new0(ifp->ctx)) == NULL)
                                return -1;
+                       memcpy(rt, r, sizeof(*rt));
+                       rt_setif(rt, ifp);
                        rt->rt_dflags = RTDF_STATIC;
-                       memcpy(rt, r, sizeof(*rt));
                        TAILQ_INSERT_TAIL(&nroutes, rt, rt_next);
                }
        } else {
@@ -407,6 +408,7 @@
                }
                if ((rth = rt_new(ifp)) == NULL)
                        return -1;
+               rth->rt_flags |= RTF_HOST;
                sa_in_init(&rth->rt_dest, &gateway->sin_addr);
                in.s_addr = INADDR_BROADCAST;
                sa_in_init(&rth->rt_netmask, &in);
diff -r 435d0c40ff17 -r 8bf13d36fddf external/bsd/dhcpcd/dist/src/route.c
--- a/external/bsd/dhcpcd/dist/src/route.c      Tue Mar 27 06:14:39 2018 +0000
+++ b/external/bsd/dhcpcd/dist/src/route.c      Fri Apr 06 10:46:37 2018 +0000
@@ -101,17 +101,13 @@
 }
 
 void
-rt_headclear(struct rt_head *rts, int af)
+rt_headclear0(struct dhcpcd_ctx *ctx, struct rt_head *rts, int af)
 {
        struct rt *rt, *rtn;
-       struct dhcpcd_ctx *ctx;
 
        if (rts == NULL)
                return;



Home | Main Index | Thread Index | Old Index