From: Siddhesh Poyarekar Date: Tue, 16 Dec 2014 11:23:05 +0000 (+0530) Subject: Fix 'array subscript is above array bounds' warning in res_send.c X-Git-Tag: upstream/2.30~6634 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a0d424ef9d7fc34f7d1a516f38c8efb1e8692a03;p=external%2Fglibc.git Fix 'array subscript is above array bounds' warning in res_send.c I see this warning in my build on F21 x86_64, which seems to be due to a weak check for array bounds. Fixed by making the bounds check stronger. This is not an actual bug since nscount is never set to anything greater than MAXNS. The compiler however does not know this, so we need the stronger bounds check to quieten the compiler. --- diff --git a/ChangeLog b/ChangeLog index 9bee819..2a3e0b7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-12-16 Siddhesh Poyarekar + + * resolv/res_send.c (__libc_res_nsend): Fix check for nsmap + bounds. + 2014-12-16 Arjun Shankar * libio/tst-fopenloc.c: Use test-skeleton.c. diff --git a/resolv/res_send.c b/resolv/res_send.c index 4a95eb8..5a9882c 100644 --- a/resolv/res_send.c +++ b/resolv/res_send.c @@ -429,7 +429,7 @@ __libc_res_nsend(res_state statp, const u_char *buf, int buflen, while (ns < MAXNS && EXT(statp).nsmap[ns] != MAXNS) ns++; - if (ns == MAXNS) + if (ns >= MAXNS) break; EXT(statp).nsmap[ns] = n; map[n] = ns++;