Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c29561cc authored by Erik Kline's avatar Erik Kline Committed by Android Git Automerger
Browse files

am 5be9e1cd: am 60adb5fa: Merge "Qualify IPv6 link-local DNS servers with an...

am 5be9e1cd: am 60adb5fa: Merge "Qualify IPv6 link-local DNS servers with an interface name" into mnc-dev

* commit '5be9e1cd':
  Qualify IPv6 link-local DNS servers with an interface name
parents 73ffc40e 5be9e1cd
Loading
Loading
Loading
Loading
+12 −6
Original line number Original line Diff line number Diff line
@@ -455,18 +455,20 @@ bool NetlinkEvent::parseNdUserOptMessage(const struct nlmsghdr *nh) {
            SLOGE("Invalid optlen %d for RDNSS option\n", optlen);
            SLOGE("Invalid optlen %d for RDNSS option\n", optlen);
            return false;
            return false;
        }
        }
        int numaddrs = (optlen - 1) / 2;
        const int numaddrs = (optlen - 1) / 2;


        // Find the lifetime.
        // Find the lifetime.
        struct nd_opt_rdnss *rndss_opt = (struct nd_opt_rdnss *) opthdr;
        struct nd_opt_rdnss *rndss_opt = (struct nd_opt_rdnss *) opthdr;
        uint32_t lifetime = ntohl(rndss_opt->nd_opt_rdnss_lifetime);
        const uint32_t lifetime = ntohl(rndss_opt->nd_opt_rdnss_lifetime);


        // Construct "SERVERS=<comma-separated string of DNS addresses>".
        // Construct "SERVERS=<comma-separated string of DNS addresses>".
        // Reserve (INET6_ADDRSTRLEN + 1) chars for each address: all but the
        // the last address are followed by ','; the last is followed by '\0'.
        static const char kServerTag[] = "SERVERS=";
        static const char kServerTag[] = "SERVERS=";
        static const int kTagLength = sizeof(kServerTag) - 1;
        static const int kTagLength = strlen(kServerTag);
        int bufsize = kTagLength + numaddrs * (INET6_ADDRSTRLEN + 1);
        // Reserve sufficient space for an IPv6 link-local address: all but the
        // last address are followed by ','; the last is followed by '\0'.
        static const int kMaxSingleAddressLength =
                INET6_ADDRSTRLEN + strlen("%") + IFNAMSIZ + strlen(",");
        const int bufsize = kTagLength + numaddrs * (INET6_ADDRSTRLEN + 1);
        char *buf = (char *) malloc(bufsize);
        char *buf = (char *) malloc(bufsize);
        if (!buf) {
        if (!buf) {
            SLOGE("RDNSS option: out of memory\n");
            SLOGE("RDNSS option: out of memory\n");
@@ -482,6 +484,10 @@ bool NetlinkEvent::parseNdUserOptMessage(const struct nlmsghdr *nh) {
            }
            }
            inet_ntop(AF_INET6, addrs + i, buf + pos, bufsize - pos);
            inet_ntop(AF_INET6, addrs + i, buf + pos, bufsize - pos);
            pos += strlen(buf + pos);
            pos += strlen(buf + pos);
            if (IN6_IS_ADDR_LINKLOCAL(addrs + i)) {
                buf[pos++] = '%';
                pos += strlcpy(buf + pos, ifname, bufsize - pos);
            }
        }
        }
        buf[pos] = '\0';
        buf[pos] = '\0';