Fix off-by-one error in res_cache.c
Change-Id: I58264902c123b3bc0d392d17837aa537ca0a3ca2
diff --git a/libc/dns/resolv/res_cache.c b/libc/dns/resolv/res_cache.c
index 526c91b..15f9aa4 100644
--- a/libc/dns/resolv/res_cache.c
+++ b/libc/dns/resolv/res_cache.c
@@ -1228,15 +1228,18 @@
PendingReqInfo pending_requests;
} Cache;
+// The nameservers[], nsaddrinfo[] and nsstats[] are containing MAXNS + 1 elements, because the
+// number of nameservers is not known and the code relies on the n+1-st entry to be null to
+// recognize the end.
struct resolv_cache_info {
unsigned netid;
Cache* cache;
struct resolv_cache_info* next;
- char* nameservers[MAXNS +1];
+ char* nameservers[MAXNS + 1];
struct addrinfo* nsaddrinfo[MAXNS + 1];
int revision_id; // # times the nameservers have been replaced
struct __res_params params;
- struct __res_stats nsstats[MAXNS];
+ struct __res_stats nsstats[MAXNS + 1];
char defdname[256];
int dnsrch_offset[MAXDNSRCH+1]; // offsets into defdname
};