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

Commit ab9762b6 authored by Luke Huang's avatar Luke Huang Committed by Gerrit Code Review
Browse files

Merge "Replace res_randomid with arc4random_uniform"

parents e0756467 dda920f7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -144,7 +144,7 @@ int res_vinit(res_state statp, int preinit) {
        statp->retrans = RES_TIMEOUT;
        statp->retry = RES_DFLRETRY;
        statp->options = RES_DEFAULT;
        statp->id = res_randomid();
        statp->id = arc4random_uniform(65536);
        statp->_mark = MARK_UNSET;
    }

+1 −1
Original line number Diff line number Diff line
@@ -125,7 +125,7 @@ int res_nmkquery(res_state statp, int op, /* opcode of query */
    if ((buf == NULL) || (buflen < HFIXEDSZ)) return (-1);
    memset(buf, 0, HFIXEDSZ);
    hp = (HEADER*) (void*) buf;
    hp->id = htons(res_randomid());
    hp->id = htons(arc4random_uniform(65536));
    hp->opcode = op;
    hp->rd = (statp->options & RES_RECURSE) != 0U;
    hp->ad = (statp->options & RES_USE_DNSSEC) != 0U;
+1 −1
Original line number Diff line number Diff line
@@ -251,7 +251,7 @@ static int random_bind(int s, int family) {
    /* first try to bind to a random source port a few times */
    for (j = 0; j < 10; j++) {
        /* find a random port between 1025 .. 65534 */
        int port = 1025 + (res_randomid() % (65535 - 1025));
        int port = 1025 + (arc4random_uniform(65535 - 1025));
        if (family == AF_INET)
            u.sin.sin_port = htons(port);
        else
+0 −2
Original line number Diff line number Diff line
@@ -250,8 +250,6 @@ int res_getservers(res_state, sockaddr_union*, int);
struct android_net_context; /* forward */
void res_setnetcontext(res_state, const struct android_net_context*);

u_int res_randomid(void);

int getaddrinfo_numeric(const char* hostname, const char* servname, addrinfo hints,
                        addrinfo** result);