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

Commit 67a2790c authored by Bernie Innocenti's avatar Bernie Innocenti
Browse files

Delete nameserver config change detection in res_nsend

Configuration changes between calls to res_nsend() are impossible,
because each thread has its own copy of res_state, and the nameservers
are copied there by _resolv_populate_res_for_net() at the very
beginning.

Another little peace of untestable code hits the dust.

Test: m, flash, atest
Change-Id: I90b48eab92f087ec0958516963655a0c43c29260
parent c977ab77
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -99,7 +99,6 @@ void res_init(res_state statp) {
    statp->id = arc4random_uniform(65536);
    statp->_mark = MARK_UNSET;

    statp->nscount = 0;
    statp->ndots = 1;
    statp->_vcsock = -1;
    statp->_flags = 0;
+0 −32
Original line number Diff line number Diff line
@@ -455,38 +455,6 @@ int res_nsend(res_state statp, const uint8_t* buf, int buflen, uint8_t* ans, int
        return -ESRCH;
    }

    /*
     * If the ns_addr_list in the resolver context has changed, then
     * invalidate our cached copy and the associated timing data.
     */
    if (statp->_u._ext.nscount != 0) {
        int needclose = 0;
        struct sockaddr_storage peer;
        socklen_t peerlen;

        if (statp->_u._ext.nscount != statp->nscount) {
            needclose++;
        } else {
            for (int ns = 0; ns < statp->nscount; ns++) {
                if (statp->_u._ext.nssocks[ns] == -1) continue;
                peerlen = sizeof(peer);
                if (getpeername(statp->_u._ext.nssocks[ns], (struct sockaddr*) (void*) &peer,
                                &peerlen) < 0) {
                    needclose++;
                    break;
                }
                if (!sock_eq((struct sockaddr*) (void*) &peer, get_nsaddr(statp, (size_t) ns))) {
                    needclose++;
                    break;
                }
            }
        }
        if (needclose) {
            res_nclose(statp);
            statp->_u._ext.nscount = 0;
        }
    }

    /*
     * Maybe initialize our private copy of the ns_addr_list.
     */