Source-Changes-HG archive

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

[src/netbsd-9]: src Pull up the following revisions, requested by roy in tick...



details:   https://anonhg.NetBSD.org/src/rev/e3f8106e96f0
branches:  netbsd-9
changeset: 458513:e3f8106e96f0
user:      martin <martin%NetBSD.org@localhost>
date:      Wed Oct 16 17:41:40 2019 +0000

description:
Pull up the following revisions, requested by roy in ticket #340:

        external/bsd/dhcpcd/dist/src/defs.h             up to 1.1.1.32
        external/bsd/dhcpcd/dist/src/dhcp.c             up to 1.29
        external/bsd/dhcpcd/dist/src/dhcpcd.c           up to 1.28
        external/bsd/dhcpcd/dist/src/ipv6.c             up to 1.6
        src/doc/3RDPARTY                                (manually edited)

Import dhcpcd-8.1.1 with the following changes:

 * IPv6: Fix a potential crash when learning interface addresses.
 * DHCP: Fix fallout from dhcpcd-8.1.0 for checksum calculation.

diffstat:

 doc/3RDPARTY                          |   8 +-
 external/bsd/dhcpcd/dist/src/defs.h   |   2 +-
 external/bsd/dhcpcd/dist/src/dhcp.c   |  74 ++++++++++++++++++++++------------
 external/bsd/dhcpcd/dist/src/dhcpcd.c |   5 +-
 external/bsd/dhcpcd/dist/src/ipv6.c   |   4 +-
 5 files changed, 58 insertions(+), 35 deletions(-)

diffs (201 lines):

diff -r ba4263d0bb39 -r e3f8106e96f0 doc/3RDPARTY
--- a/doc/3RDPARTY      Wed Oct 16 17:32:17 2019 +0000
+++ b/doc/3RDPARTY      Wed Oct 16 17:41:40 2019 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: 3RDPARTY,v 1.1640.2.4 2019/10/12 14:44:31 martin Exp $
+#      $NetBSD: 3RDPARTY,v 1.1640.2.5 2019/10/16 17:41:40 martin Exp $
 #
 # This file contains a list of the software that has been integrated into
 # NetBSD where we are not the primary maintainer.
@@ -341,12 +341,12 @@
 Use the dhcp2netbsd script.
 
 Package:       dhcpcd
-Version:       8.1.0
-Current Vers:  8.1.0
+Version:       8.1.1
+Current Vers:  8.1.1
 Maintainer:    roy
 Archive Site:  ftp://roy.marples.name/pub/dhcpcd/
 Home Page:     http://roy.marples.name/projects/dhcpcd/
-Date:          2019-10-12
+Date:          2019-10-16
 Mailing List:  dhcpcd-discuss%marples.name@localhost
 License:       BSD (2-clause)
 Location:      external/bsd/dhcpcd/dist
diff -r ba4263d0bb39 -r e3f8106e96f0 external/bsd/dhcpcd/dist/src/defs.h
--- a/external/bsd/dhcpcd/dist/src/defs.h       Wed Oct 16 17:32:17 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/defs.h       Wed Oct 16 17:41:40 2019 +0000
@@ -29,7 +29,7 @@
 #define CONFIG_H
 
 #define PACKAGE                        "dhcpcd"
-#define VERSION                        "8.1.0"
+#define VERSION                        "8.1.1"
 
 #ifndef CONFIG
 # define CONFIG                        SYSCONFDIR "/" PACKAGE ".conf"
diff -r ba4263d0bb39 -r e3f8106e96f0 external/bsd/dhcpcd/dist/src/dhcp.c
--- a/external/bsd/dhcpcd/dist/src/dhcp.c       Wed Oct 16 17:32:17 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcp.c       Wed Oct 16 17:41:40 2019 +0000
@@ -164,8 +164,6 @@
        }
 }
 
-#define get_option_raw(ctx, bootp, bootp_len, opt)     \
-       get_option((ctx), (bootp), (bootp_len), NULL)
 static const uint8_t *
 get_option(struct dhcpcd_ctx *ctx,
     const struct bootp *bootp, size_t bootp_len,
@@ -3275,26 +3273,35 @@
 {
        struct ip *ip = packet;
        size_t ip_hlen;
-       struct udphdr *udp;
-
-       if (sizeof(*ip) > plen)
+       struct udphdr udp;
+
+       if (plen < sizeof(*ip))
                return false;
 
        if (ip->ip_v != IPVERSION || ip->ip_p != IPPROTO_UDP)
                return false;
 
        /* Sanity. */
-       if (ntohs(ip->ip_len) != plen)
+       if (ntohs(ip->ip_len) > plen)
                return false;
 
        ip_hlen = (size_t)ip->ip_hl * 4;
+       if (ip_hlen < sizeof(*ip))
+               return false;
+
        /* Check we have a UDP header and BOOTP. */
-       if (ip_hlen + sizeof(*udp) + offsetof(struct bootp, vend) > plen)
+       if (ip_hlen + sizeof(udp) + offsetof(struct bootp, vend) > plen)
+               return false;
+
+       /* Sanity. */
+       memcpy(&udp, (char *)ip + ip_hlen, sizeof(udp));
+       if (ntohs(udp.uh_ulen) < sizeof(udp))
+               return false;
+       if (ip_hlen + ntohs(udp.uh_ulen) > plen)
                return false;
 
        /* Check it's to and from the right ports. */
-       udp = (struct udphdr *)(void *)((char *)ip + ip_hlen);
-       if (udp->uh_dport != htons(BOOTPC) || udp->uh_sport != htons(BOOTPS))
+       if (udp.uh_dport != htons(BOOTPC) || udp.uh_sport != htons(BOOTPS))
                return false;
 
        return true;
@@ -3306,14 +3313,17 @@
     struct in_addr *from, unsigned int flags)
 {
        struct ip *ip = packet;
-       struct ip pseudo_ip = {
-               .ip_p = IPPROTO_UDP,
-               .ip_src = ip->ip_src,
-               .ip_dst = ip->ip_dst
+       union pip {
+               struct ip ip;
+               uint16_t w[sizeof(struct ip)];
+       } pip = {
+               .ip.ip_p = IPPROTO_UDP,
+               .ip.ip_src = ip->ip_src,
+               .ip.ip_dst = ip->ip_dst,
        };
        size_t ip_hlen;
-       uint16_t udp_len, uh_sum;
-       struct udphdr *udp;
+       struct udphdr udp;
+       char *udpp, *uh_sump;
        uint32_t csum;
 
        if (from != NULL)
@@ -3324,22 +3334,32 @@
                return false;
 
        if (flags & BPF_PARTIALCSUM)
-               return 0;
-
-       udp = (struct udphdr *)(void *)((char *)ip + ip_hlen);
-       if (udp->uh_sum == 0)
-               return 0;
+               return true;
+
+       udpp = (char *)ip + ip_hlen;
+       memcpy(&udp, udpp, sizeof(udp));
+       if (udp.uh_sum == 0)
+               return true;
 
        /* UDP checksum is based on a pseudo IP header alongside
         * the UDP header and payload. */
-       udp_len = ntohs(udp->uh_ulen);
-       uh_sum = udp->uh_sum;
-       udp->uh_sum = 0;
-       pseudo_ip.ip_len = udp->uh_ulen;
+       pip.ip.ip_len = udp.uh_ulen;
        csum = 0;
-       in_cksum(&pseudo_ip, sizeof(pseudo_ip), &csum);
-       csum = in_cksum(udp, udp_len, &csum);
-       return csum == uh_sum;
+
+       /* Need to zero the UDP sum in the packet for the checksum to work. */
+       uh_sump = udpp + offsetof(struct udphdr, uh_sum);
+       memset(uh_sump, 0, sizeof(udp.uh_sum));
+
+       /* Checksum psuedo header and then UDP + payload. */
+       in_cksum(pip.w, sizeof(pip.w), &csum);
+       csum = in_cksum(udpp, ntohs(udp.uh_ulen), &csum);
+
+#if 0  /* Not needed, just here for completeness. */
+       /* Put the checksum back. */
+       memcpy(uh_sump, &udp.uh_sum, sizeof(udp.uh_sum));
+#endif
+
+       return csum == udp.uh_sum;
 }
 
 static void
diff -r ba4263d0bb39 -r e3f8106e96f0 external/bsd/dhcpcd/dist/src/dhcpcd.c
--- a/external/bsd/dhcpcd/dist/src/dhcpcd.c     Wed Oct 16 17:32:17 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcpcd.c     Wed Oct 16 17:41:40 2019 +0000
@@ -1984,12 +1984,10 @@
        logdebugx(PACKAGE "-" VERSION " starting");
        ctx.options |= DHCPCD_STARTED;
 
-#ifdef HAVE_SETPROCTITLE
        setproctitle("%s%s%s",
            ctx.options & DHCPCD_MASTER ? "[master]" : argv[optind],
            ctx.options & DHCPCD_IPV4 ? " [ip4]" : "",
            ctx.options & DHCPCD_IPV6 ? " [ip6]" : "");
-#endif
 
        if (if_opensockets(&ctx) == -1) {
                logerr("%s: if_opensockets", __func__);
@@ -2155,6 +2153,9 @@
                loginfox(PACKAGE " exited");
        logclose();
        free(ctx.logfile);
+#ifdef SETPROCTITLE_H
+       setproctitle_free();
+#endif
 #ifdef USE_SIGNALS
        if (ctx.options & DHCPCD_FORKED)
                _exit(i); /* so atexit won't remove our pidfile */
diff -r ba4263d0bb39 -r e3f8106e96f0 external/bsd/dhcpcd/dist/src/ipv6.c
--- a/external/bsd/dhcpcd/dist/src/ipv6.c       Wed Oct 16 17:32:17 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/ipv6.c       Wed Oct 16 17:41:40 2019 +0000
@@ -1253,7 +1253,9 @@
         * or DHCP6 handlers and the existance of any useable
         * global address on the interface has changed,
         * call rt_build to add/remove the default route. */
-       if (ifp->active && ifp->options->options & DHCPCD_IPV6 &&
+       if (ifp->active &&
+           ((ifp->options != NULL && ifp->options->options & DHCPCD_IPV6) ||
+            (ifp->options == NULL && ctx->options & DHCPCD_IPV6)) &&
            !(ctx->options & DHCPCD_RTBUILD) &&
            (ipv6_anyglobal(ifp) != NULL) != anyglobal)
                rt_build(ctx, AF_INET6);



Home | Main Index | Thread Index | Old Index