From a0d424ef9d7fc34f7d1a516f38c8efb1e8692a03 Mon Sep 17 00:00:00 2001 From: Siddhesh Poyarekar Date: Tue, 16 Dec 2014 16:53:05 +0530 Subject: [PATCH] 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. --- ChangeLog | 5 +++++ resolv/res_send.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) 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++; -- 2.7.4