Loading DnsProxyListener.cpp +0 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,6 @@ #include <stdlib.h> #include <string.h> #include <sys/socket.h> #include <sys/types.h> #define LOG_TAG "resolv" Loading getaddrinfo.cpp +12 −13 Original line number Diff line number Diff line Loading @@ -50,7 +50,6 @@ #include <sys/param.h> #include <sys/socket.h> #include <sys/stat.h> #include <sys/types.h> #include <sys/un.h> #include <unistd.h> Loading Loading @@ -112,14 +111,14 @@ const Explore explore_options[] = { typedef union { HEADER hdr; u_char buf[MAXPACKET]; uint8_t buf[MAXPACKET]; } querybuf; struct res_target { struct res_target* next; const char* name; /* domain name */ int qclass, qtype; /* class and type of query */ u_char* answer; /* buffer to put answer */ uint8_t* answer; /* buffer to put answer */ int anslen; /* size of answer buffer */ int n; /* result length */ }; Loading @@ -137,7 +136,7 @@ static struct addrinfo* get_ai(const struct addrinfo*, const struct afd*, const static int get_portmatch(const struct addrinfo*, const char*); static int get_port(const struct addrinfo*, const char*, int); static const struct afd* find_afd(int); static int ip6_str2scopeid(const char*, struct sockaddr_in6*, u_int32_t*); static int ip6_str2scopeid(const char*, struct sockaddr_in6*, uint32_t*); static struct addrinfo* getanswer(const querybuf*, int, const char*, int, const struct addrinfo*, int* herrno); Loading Loading @@ -646,7 +645,7 @@ static int explore_numeric_scope(const struct addrinfo* pai, const char* hostnam error = explore_numeric(pai, addr, servname, res, hostname); if (error == 0) { u_int32_t scopeid; uint32_t scopeid; for (cur = *res; cur; cur = cur->ai_next) { if (cur->ai_family != AF_INET6) continue; Loading Loading @@ -787,8 +786,8 @@ static const struct afd* find_afd(int af) { } // Convert a string to a scope identifier. static int ip6_str2scopeid(const char* scope, struct sockaddr_in6* sin6, u_int32_t* scopeid) { u_long lscopeid; static int ip6_str2scopeid(const char* scope, struct sockaddr_in6* sin6, uint32_t* scopeid) { uint64_t lscopeid; struct in6_addr* a6; char* ep; Loading @@ -814,7 +813,7 @@ static int ip6_str2scopeid(const char* scope, struct sockaddr_in6* sin6, u_int32 // try to convert to a numeric id as a last resort errno = 0; lscopeid = strtoul(scope, &ep, 10); *scopeid = (u_int32_t)(lscopeid & 0xffffffffUL); *scopeid = (uint32_t)(lscopeid & 0xffffffffUL); if (errno == 0 && ep && *ep == '\0' && *scopeid == lscopeid) return 0; else Loading Loading @@ -845,9 +844,9 @@ static struct addrinfo* getanswer(const querybuf* answer, int anslen, const char const struct afd* afd; char* canonname; const HEADER* hp; const u_char* cp; const uint8_t* cp; int n; const u_char* eom; const uint8_t* eom; char *bp, *ep; int type, ancount, qdcount; int haveanswer, had_error; Loading Loading @@ -1583,7 +1582,7 @@ static bool files_getaddrinfo(const char* name, const addrinfo* pai, addrinfo** * Caller must parse answer and determine whether it answers the question. */ static int res_queryN(const char* name, res_target* target, res_state res, int* herrno) { u_char buf[MAXPACKET]; uint8_t buf[MAXPACKET]; HEADER* hp; int n; struct res_target* t; Loading @@ -1597,7 +1596,7 @@ static int res_queryN(const char* name, res_target* target, res_state res, int* ancount = 0; for (t = target; t; t = t->next) { u_char* answer; uint8_t* answer; int anslen; hp = (HEADER*) (void*) t->answer; Loading Loading @@ -1687,7 +1686,7 @@ static int res_queryN(const char* name, res_target* target, res_state res, int* static int res_searchN(const char* name, res_target* target, res_state res, int* herrno) { const char* cp; HEADER* hp; u_int dots; uint32_t dots; int ret, saved_herrno; int got_nodata = 0, got_servfail = 0, tried_as_is = 0; Loading gethnamaddr.cpp +10 −11 Original line number Diff line number Diff line Loading @@ -67,7 +67,6 @@ #include <string.h> #include <sys/param.h> #include <sys/socket.h> #include <sys/types.h> #include <sys/un.h> #include <unistd.h> #include <functional> Loading Loading @@ -99,7 +98,7 @@ using android::net::NetworkDnsEventReported; typedef union { HEADER hdr; u_char buf[MAXPACKET]; uint8_t buf[MAXPACKET]; } querybuf; typedef union { Loading Loading @@ -149,10 +148,10 @@ static struct hostent* getanswer(const querybuf* answer, int anslen, const char* res_state res, struct hostent* hent, char* buf, size_t buflen, int* he) { const HEADER* hp; const u_char* cp; const uint8_t* cp; int n; size_t qlen; const u_char *eom, *erdata; const uint8_t *eom, *erdata; char *bp, **hap, *ep; int ancount, qdcount; int haveanswer, had_error; Loading Loading @@ -344,7 +343,7 @@ static struct hostent* getanswer(const querybuf* answer, int anslen, const char* bp += nn; } bp += sizeof(align) - (size_t)((u_long) bp % sizeof(align)); bp += sizeof(align) - (size_t)((uintptr_t)bp % sizeof(align)); if (bp + n >= ep) { LOG(DEBUG) << __func__ << ": size (" << n << ") too big"; Loading Loading @@ -437,7 +436,7 @@ static int gethostbyname_internal_real(const char* name, int af, hostent* hp, ch * disallow names consisting only of digits/dots, unless * they end in a dot. */ if (isdigit((u_char) name[0])) { if (isdigit((uint8_t)name[0])) { for (const char* cp = name;; ++cp) { if (!*cp) { if (*--cp == '.') break; Loading @@ -448,10 +447,10 @@ static int gethostbyname_internal_real(const char* name, int af, hostent* hp, ch */ goto fake; } if (!isdigit((u_char) *cp) && *cp != '.') break; if (!isdigit((uint8_t)*cp) && *cp != '.') break; } } if ((isxdigit((u_char) name[0]) && strchr(name, ':') != NULL) || name[0] == ':') { if ((isxdigit((uint8_t)name[0]) && strchr(name, ':') != NULL) || name[0] == ':') { for (const char* cp = name;; ++cp) { if (!*cp) { if (*--cp == '.') break; Loading @@ -462,7 +461,7 @@ static int gethostbyname_internal_real(const char* name, int af, hostent* hp, ch */ goto fake; } if (!isxdigit((u_char) *cp) && *cp != ':' && *cp != '.') break; if (!isxdigit((uint8_t)*cp) && *cp != ':' && *cp != '.') break; } } Loading Loading @@ -506,7 +505,7 @@ static int android_gethostbyaddrfornetcontext_real(const void* addr, socklen_t l struct hostent* hp, char* buf, size_t buflen, const struct android_net_context* netcontext, NetworkDnsEventReported* event) { const u_char* uaddr = (const u_char*) addr; const uint8_t* uaddr = (const uint8_t*)addr; socklen_t size; struct getnamaddr info; Loading Loading @@ -666,7 +665,7 @@ static void convert_v4v6_hostent(struct hostent* hp, char** bpp, char* ep, if (hp->h_addrtype != AF_INET || hp->h_length != NS_INADDRSZ) return; map_param(hp); for (char** ap = hp->h_addr_list; *ap; ap++) { int i = (int) (sizeof(align) - (size_t)((u_long) *bpp % sizeof(align))); int i = (int)(sizeof(align) - (size_t)((uintptr_t)*bpp % sizeof(align))); if (ep - *bpp < (i + NS_IN6ADDRSZ)) { /* Out of memory. Truncate address list here. XXX */ Loading res_cache.cpp +9 −9 Original line number Diff line number Diff line Loading @@ -697,18 +697,18 @@ typedef struct Entry { * * Return 0 if not found. */ static u_long answer_getNegativeTTL(ns_msg handle) { static uint32_t answer_getNegativeTTL(ns_msg handle) { int n, nscount; u_long result = 0; uint32_t result = 0; ns_rr rr; nscount = ns_msg_count(handle, ns_s_ns); for (n = 0; n < nscount; n++) { if ((ns_parserr(&handle, ns_s_ns, n, &rr) == 0) && (ns_rr_type(rr) == ns_t_soa)) { const u_char* rdata = ns_rr_rdata(rr); // find the data const u_char* edata = rdata + ns_rr_rdlen(rr); // add the len to find the end const uint8_t* rdata = ns_rr_rdata(rr); // find the data const uint8_t* edata = rdata + ns_rr_rdlen(rr); // add the len to find the end int len; u_long ttl, rec_result = ns_rr_ttl(rr); uint32_t ttl, rec_result = rr.ttl; // find the MINIMUM-TTL field from the blob of binary data for this record // skip the server name Loading Loading @@ -750,10 +750,10 @@ static u_long answer_getNegativeTTL(ns_msg handle) { * In case of parse error zero (0) is returned which * indicates that the answer shall not be cached. */ static u_long answer_getTTL(const void* answer, int answerlen) { static uint32_t answer_getTTL(const void* answer, int answerlen) { ns_msg handle; int ancount, n; u_long result, ttl; uint32_t result, ttl; ns_rr rr; result = 0; Loading @@ -767,7 +767,7 @@ static u_long answer_getTTL(const void* answer, int answerlen) { } else { for (n = 0; n < ancount; n++) { if (ns_parserr(&handle, ns_s_an, n, &rr) == 0) { ttl = ns_rr_ttl(rr); ttl = rr.ttl; if (n == 0 || ttl < result) { result = ttl; } Loading Loading @@ -1251,7 +1251,7 @@ int resolv_cache_add(unsigned netid, const void* query, int querylen, const void Entry key[1]; Entry* e; Entry** lookup; u_long ttl; uint32_t ttl; Cache* cache = NULL; /* don't assume that the query has already been cached Loading res_comp.cpp +6 −8 Original line number Diff line number Diff line Loading @@ -73,8 +73,6 @@ #include <arpa/nameser.h> #include <ctype.h> #include <netinet/in.h> #include <sys/param.h> #include <sys/types.h> #include <string.h> #include <unistd.h> Loading @@ -87,7 +85,7 @@ * 'dst' is a pointer to a buffer of size 'dstsiz' for the result. * Return size of compressed name or -1 if there was an error. */ int dn_expand(const u_char* msg, const u_char* eom, const u_char* src, char* dst, int dstsiz) { int dn_expand(const uint8_t* msg, const uint8_t* eom, const uint8_t* src, char* dst, int dstsiz) { int n = ns_name_uncompress(msg, eom, src, dst, (size_t) dstsiz); if (n > 0 && dst[0] == '.') dst[0] = '\0'; Loading @@ -99,16 +97,16 @@ int dn_expand(const u_char* msg, const u_char* eom, const u_char* src, char* dst * Return the size of the compressed name or -1. * 'length' is the size of the array pointed to by 'comp_dn'. */ int dn_comp(const char* src, u_char* dst, int dstsiz, u_char** dnptrs, u_char** lastdnptr) { return (ns_name_compress(src, dst, (size_t) dstsiz, (const u_char**) dnptrs, (const u_char**) lastdnptr)); int dn_comp(const char* src, uint8_t* dst, int dstsiz, uint8_t** dnptrs, uint8_t** lastdnptr) { return (ns_name_compress(src, dst, (size_t)dstsiz, (const uint8_t**)dnptrs, (const uint8_t**)lastdnptr)); } /* * Skip over a compressed domain name. Return the size or -1. */ int dn_skipname(const u_char* ptr, const u_char* eom) { const u_char* saveptr = ptr; int dn_skipname(const uint8_t* ptr, const uint8_t* eom) { const uint8_t* saveptr = ptr; if (ns_name_skip(&ptr, eom) == -1) return (-1); return (ptr - saveptr); Loading Loading
DnsProxyListener.cpp +0 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,6 @@ #include <stdlib.h> #include <string.h> #include <sys/socket.h> #include <sys/types.h> #define LOG_TAG "resolv" Loading
getaddrinfo.cpp +12 −13 Original line number Diff line number Diff line Loading @@ -50,7 +50,6 @@ #include <sys/param.h> #include <sys/socket.h> #include <sys/stat.h> #include <sys/types.h> #include <sys/un.h> #include <unistd.h> Loading Loading @@ -112,14 +111,14 @@ const Explore explore_options[] = { typedef union { HEADER hdr; u_char buf[MAXPACKET]; uint8_t buf[MAXPACKET]; } querybuf; struct res_target { struct res_target* next; const char* name; /* domain name */ int qclass, qtype; /* class and type of query */ u_char* answer; /* buffer to put answer */ uint8_t* answer; /* buffer to put answer */ int anslen; /* size of answer buffer */ int n; /* result length */ }; Loading @@ -137,7 +136,7 @@ static struct addrinfo* get_ai(const struct addrinfo*, const struct afd*, const static int get_portmatch(const struct addrinfo*, const char*); static int get_port(const struct addrinfo*, const char*, int); static const struct afd* find_afd(int); static int ip6_str2scopeid(const char*, struct sockaddr_in6*, u_int32_t*); static int ip6_str2scopeid(const char*, struct sockaddr_in6*, uint32_t*); static struct addrinfo* getanswer(const querybuf*, int, const char*, int, const struct addrinfo*, int* herrno); Loading Loading @@ -646,7 +645,7 @@ static int explore_numeric_scope(const struct addrinfo* pai, const char* hostnam error = explore_numeric(pai, addr, servname, res, hostname); if (error == 0) { u_int32_t scopeid; uint32_t scopeid; for (cur = *res; cur; cur = cur->ai_next) { if (cur->ai_family != AF_INET6) continue; Loading Loading @@ -787,8 +786,8 @@ static const struct afd* find_afd(int af) { } // Convert a string to a scope identifier. static int ip6_str2scopeid(const char* scope, struct sockaddr_in6* sin6, u_int32_t* scopeid) { u_long lscopeid; static int ip6_str2scopeid(const char* scope, struct sockaddr_in6* sin6, uint32_t* scopeid) { uint64_t lscopeid; struct in6_addr* a6; char* ep; Loading @@ -814,7 +813,7 @@ static int ip6_str2scopeid(const char* scope, struct sockaddr_in6* sin6, u_int32 // try to convert to a numeric id as a last resort errno = 0; lscopeid = strtoul(scope, &ep, 10); *scopeid = (u_int32_t)(lscopeid & 0xffffffffUL); *scopeid = (uint32_t)(lscopeid & 0xffffffffUL); if (errno == 0 && ep && *ep == '\0' && *scopeid == lscopeid) return 0; else Loading Loading @@ -845,9 +844,9 @@ static struct addrinfo* getanswer(const querybuf* answer, int anslen, const char const struct afd* afd; char* canonname; const HEADER* hp; const u_char* cp; const uint8_t* cp; int n; const u_char* eom; const uint8_t* eom; char *bp, *ep; int type, ancount, qdcount; int haveanswer, had_error; Loading Loading @@ -1583,7 +1582,7 @@ static bool files_getaddrinfo(const char* name, const addrinfo* pai, addrinfo** * Caller must parse answer and determine whether it answers the question. */ static int res_queryN(const char* name, res_target* target, res_state res, int* herrno) { u_char buf[MAXPACKET]; uint8_t buf[MAXPACKET]; HEADER* hp; int n; struct res_target* t; Loading @@ -1597,7 +1596,7 @@ static int res_queryN(const char* name, res_target* target, res_state res, int* ancount = 0; for (t = target; t; t = t->next) { u_char* answer; uint8_t* answer; int anslen; hp = (HEADER*) (void*) t->answer; Loading Loading @@ -1687,7 +1686,7 @@ static int res_queryN(const char* name, res_target* target, res_state res, int* static int res_searchN(const char* name, res_target* target, res_state res, int* herrno) { const char* cp; HEADER* hp; u_int dots; uint32_t dots; int ret, saved_herrno; int got_nodata = 0, got_servfail = 0, tried_as_is = 0; Loading
gethnamaddr.cpp +10 −11 Original line number Diff line number Diff line Loading @@ -67,7 +67,6 @@ #include <string.h> #include <sys/param.h> #include <sys/socket.h> #include <sys/types.h> #include <sys/un.h> #include <unistd.h> #include <functional> Loading Loading @@ -99,7 +98,7 @@ using android::net::NetworkDnsEventReported; typedef union { HEADER hdr; u_char buf[MAXPACKET]; uint8_t buf[MAXPACKET]; } querybuf; typedef union { Loading Loading @@ -149,10 +148,10 @@ static struct hostent* getanswer(const querybuf* answer, int anslen, const char* res_state res, struct hostent* hent, char* buf, size_t buflen, int* he) { const HEADER* hp; const u_char* cp; const uint8_t* cp; int n; size_t qlen; const u_char *eom, *erdata; const uint8_t *eom, *erdata; char *bp, **hap, *ep; int ancount, qdcount; int haveanswer, had_error; Loading Loading @@ -344,7 +343,7 @@ static struct hostent* getanswer(const querybuf* answer, int anslen, const char* bp += nn; } bp += sizeof(align) - (size_t)((u_long) bp % sizeof(align)); bp += sizeof(align) - (size_t)((uintptr_t)bp % sizeof(align)); if (bp + n >= ep) { LOG(DEBUG) << __func__ << ": size (" << n << ") too big"; Loading Loading @@ -437,7 +436,7 @@ static int gethostbyname_internal_real(const char* name, int af, hostent* hp, ch * disallow names consisting only of digits/dots, unless * they end in a dot. */ if (isdigit((u_char) name[0])) { if (isdigit((uint8_t)name[0])) { for (const char* cp = name;; ++cp) { if (!*cp) { if (*--cp == '.') break; Loading @@ -448,10 +447,10 @@ static int gethostbyname_internal_real(const char* name, int af, hostent* hp, ch */ goto fake; } if (!isdigit((u_char) *cp) && *cp != '.') break; if (!isdigit((uint8_t)*cp) && *cp != '.') break; } } if ((isxdigit((u_char) name[0]) && strchr(name, ':') != NULL) || name[0] == ':') { if ((isxdigit((uint8_t)name[0]) && strchr(name, ':') != NULL) || name[0] == ':') { for (const char* cp = name;; ++cp) { if (!*cp) { if (*--cp == '.') break; Loading @@ -462,7 +461,7 @@ static int gethostbyname_internal_real(const char* name, int af, hostent* hp, ch */ goto fake; } if (!isxdigit((u_char) *cp) && *cp != ':' && *cp != '.') break; if (!isxdigit((uint8_t)*cp) && *cp != ':' && *cp != '.') break; } } Loading Loading @@ -506,7 +505,7 @@ static int android_gethostbyaddrfornetcontext_real(const void* addr, socklen_t l struct hostent* hp, char* buf, size_t buflen, const struct android_net_context* netcontext, NetworkDnsEventReported* event) { const u_char* uaddr = (const u_char*) addr; const uint8_t* uaddr = (const uint8_t*)addr; socklen_t size; struct getnamaddr info; Loading Loading @@ -666,7 +665,7 @@ static void convert_v4v6_hostent(struct hostent* hp, char** bpp, char* ep, if (hp->h_addrtype != AF_INET || hp->h_length != NS_INADDRSZ) return; map_param(hp); for (char** ap = hp->h_addr_list; *ap; ap++) { int i = (int) (sizeof(align) - (size_t)((u_long) *bpp % sizeof(align))); int i = (int)(sizeof(align) - (size_t)((uintptr_t)*bpp % sizeof(align))); if (ep - *bpp < (i + NS_IN6ADDRSZ)) { /* Out of memory. Truncate address list here. XXX */ Loading
res_cache.cpp +9 −9 Original line number Diff line number Diff line Loading @@ -697,18 +697,18 @@ typedef struct Entry { * * Return 0 if not found. */ static u_long answer_getNegativeTTL(ns_msg handle) { static uint32_t answer_getNegativeTTL(ns_msg handle) { int n, nscount; u_long result = 0; uint32_t result = 0; ns_rr rr; nscount = ns_msg_count(handle, ns_s_ns); for (n = 0; n < nscount; n++) { if ((ns_parserr(&handle, ns_s_ns, n, &rr) == 0) && (ns_rr_type(rr) == ns_t_soa)) { const u_char* rdata = ns_rr_rdata(rr); // find the data const u_char* edata = rdata + ns_rr_rdlen(rr); // add the len to find the end const uint8_t* rdata = ns_rr_rdata(rr); // find the data const uint8_t* edata = rdata + ns_rr_rdlen(rr); // add the len to find the end int len; u_long ttl, rec_result = ns_rr_ttl(rr); uint32_t ttl, rec_result = rr.ttl; // find the MINIMUM-TTL field from the blob of binary data for this record // skip the server name Loading Loading @@ -750,10 +750,10 @@ static u_long answer_getNegativeTTL(ns_msg handle) { * In case of parse error zero (0) is returned which * indicates that the answer shall not be cached. */ static u_long answer_getTTL(const void* answer, int answerlen) { static uint32_t answer_getTTL(const void* answer, int answerlen) { ns_msg handle; int ancount, n; u_long result, ttl; uint32_t result, ttl; ns_rr rr; result = 0; Loading @@ -767,7 +767,7 @@ static u_long answer_getTTL(const void* answer, int answerlen) { } else { for (n = 0; n < ancount; n++) { if (ns_parserr(&handle, ns_s_an, n, &rr) == 0) { ttl = ns_rr_ttl(rr); ttl = rr.ttl; if (n == 0 || ttl < result) { result = ttl; } Loading Loading @@ -1251,7 +1251,7 @@ int resolv_cache_add(unsigned netid, const void* query, int querylen, const void Entry key[1]; Entry* e; Entry** lookup; u_long ttl; uint32_t ttl; Cache* cache = NULL; /* don't assume that the query has already been cached Loading
res_comp.cpp +6 −8 Original line number Diff line number Diff line Loading @@ -73,8 +73,6 @@ #include <arpa/nameser.h> #include <ctype.h> #include <netinet/in.h> #include <sys/param.h> #include <sys/types.h> #include <string.h> #include <unistd.h> Loading @@ -87,7 +85,7 @@ * 'dst' is a pointer to a buffer of size 'dstsiz' for the result. * Return size of compressed name or -1 if there was an error. */ int dn_expand(const u_char* msg, const u_char* eom, const u_char* src, char* dst, int dstsiz) { int dn_expand(const uint8_t* msg, const uint8_t* eom, const uint8_t* src, char* dst, int dstsiz) { int n = ns_name_uncompress(msg, eom, src, dst, (size_t) dstsiz); if (n > 0 && dst[0] == '.') dst[0] = '\0'; Loading @@ -99,16 +97,16 @@ int dn_expand(const u_char* msg, const u_char* eom, const u_char* src, char* dst * Return the size of the compressed name or -1. * 'length' is the size of the array pointed to by 'comp_dn'. */ int dn_comp(const char* src, u_char* dst, int dstsiz, u_char** dnptrs, u_char** lastdnptr) { return (ns_name_compress(src, dst, (size_t) dstsiz, (const u_char**) dnptrs, (const u_char**) lastdnptr)); int dn_comp(const char* src, uint8_t* dst, int dstsiz, uint8_t** dnptrs, uint8_t** lastdnptr) { return (ns_name_compress(src, dst, (size_t)dstsiz, (const uint8_t**)dnptrs, (const uint8_t**)lastdnptr)); } /* * Skip over a compressed domain name. Return the size or -1. */ int dn_skipname(const u_char* ptr, const u_char* eom) { const u_char* saveptr = ptr; int dn_skipname(const uint8_t* ptr, const uint8_t* eom) { const uint8_t* saveptr = ptr; if (ns_name_skip(&ptr, eom) == -1) return (-1); return (ptr - saveptr); Loading