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

Commit 0d4c3e3b authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker Committed by Automerger Merge Worker
Browse files
parents 1581850e 5900e828
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -1439,11 +1439,6 @@ static int dns_getaddrinfo(const char* name, const addrinfo* pai,

    setMdnsFlag(name, res.netid, &(res.flags));

    if (isMdnsResolution(res.flags)) {
        q.qclass |= C_UNICAST;
        q2.qclass |= C_UNICAST;
    }

    int he;
    if (res_searchN(name, &q, &res, &he) < 0) {
        // Return h_errno (he) to catch more detailed errors rather than EAI_NODATA.
+1 −2
Original line number Diff line number Diff line
@@ -633,8 +633,7 @@ static int dns_gethtbyname(ResState* res, const char* name, int addr_type, getna
    auto buf = std::make_unique<querybuf>();

    int he;
    const unsigned qclass = isMdnsResolution(res->flags) ? C_IN | C_UNICAST : C_IN;
    n = res_nsearch(res, name, qclass, type, {buf->buf, (int)sizeof(buf->buf)}, &he);
    n = res_nsearch(res, name, C_IN, type, {buf->buf, (int)sizeof(buf->buf)}, &he);
    if (n < 0) {
        LOG(DEBUG) << __func__ << ": res_nsearch failed (" << n << ")";
        // Return h_errno (he) to catch more detailed errors rather than EAI_NODATA.
+1 −3
Original line number Diff line number Diff line
@@ -260,7 +260,6 @@ static time_t _time_now(void) {
#define DNS_TYPE_ALL "\00\0377" /* big-endian decimal 255 */

#define DNS_CLASS_IN "\00\01" /* big-endian decimal 1 */
#define MDNS_CLASS_UNICAST_IN "\200\01" /* big-endian decimal 32769 */

struct DnsPacket {
    const uint8_t* base;
@@ -375,8 +374,7 @@ static int _dnsPacket_checkQR(DnsPacket* packet) {
        return 0;
    }
    /* CLASS must be IN */
    if (!_dnsPacket_checkBytes(packet, 2, DNS_CLASS_IN) &&
        !_dnsPacket_checkBytes(packet, 2, MDNS_CLASS_UNICAST_IN)) {
    if (!_dnsPacket_checkBytes(packet, 2, DNS_CLASS_IN)) {
        LOG(INFO) << __func__ << ": unsupported CLASS";
        return 0;
    }
+9 −3
Original line number Diff line number Diff line
@@ -253,7 +253,7 @@ static struct timespec evNowTime(void) {
// END: Code copied from ISC eventlib

/* BIONIC-BEGIN: implement source port randomization */
static int random_bind(int s, int family) {
static int random_bind(int s, int family, bool isMdns) {
    sockaddr_union u;
    int j;
    socklen_t slen;
@@ -279,6 +279,10 @@ static int random_bind(int s, int family) {
    for (j = 0; j < 10; j++) {
        /* find a random port between 1025 .. 65534 */
        int port = 1025 + (arc4random_uniform(65535 - 1025));
        // RFC 6762 section 5.1: Don't use 5353 source port on one-shot Multicast DNS queries. DNS
        // resolver does not fully compliant mDNS.
        if (isMdns && port == 5353) continue;

        if (family == AF_INET)
            u.sin.sin_port = htons(port);
        else
@@ -775,7 +779,7 @@ same_ns:
            }
        }
        errno = 0;
        if (random_bind(statp->tcp_nssock, nsap->sa_family) < 0) {
        if (random_bind(statp->tcp_nssock, nsap->sa_family, false /* isMdns */) < 0) {
            *terrno = errno;
            dump_error("bind/vc", nsap);
            statp->closeSockets();
@@ -1078,7 +1082,9 @@ static int setupUdpSocket(ResState* statp, const sockaddr* sockap, unique_fd* fd
        }
    }

    if (random_bind(*fd_out, sockap->sa_family) < 0) {
    const auto addr = IPSockAddr::toIPSockAddr(*sockap);
    const bool isMdns = (addr == mdns_addrs[0] || addr == mdns_addrs[1]);
    if (random_bind(*fd_out, sockap->sa_family, isMdns) < 0) {
        *terrno = errno;
        dump_error("bind", sockap);
        return 0;
+0 −2
Original line number Diff line number Diff line
@@ -89,8 +89,6 @@ union sockaddr_union {
};
constexpr int MAXPACKET = 8 * 1024;

const unsigned C_UNICAST = 0x8000;  // unicast-response bit for MDNS

struct ResState {
    ResState(const android_net_context* netcontext, android::net::NetworkDnsEventReported* dnsEvent)
        : netid(netcontext->dns_netid),
Loading