]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix 'array subscript is above array bounds' warning in res_send.c
authorSiddhesh Poyarekar <siddhesh@redhat.com>
Tue, 16 Dec 2014 11:23:05 +0000 (16:53 +0530)
committerSiddhesh Poyarekar <siddhesh@redhat.com>
Tue, 16 Dec 2014 11:25:23 +0000 (16:55 +0530)
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
resolv/res_send.c

index 9bee8199a135a00af0c3f85fa6e0bb90bc390453..2a3e0b7bf2d2515c127c09de1c15454398abbfeb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2014-12-16  Siddhesh Poyarekar  <siddhesh@redhat.com>
+
+       * resolv/res_send.c (__libc_res_nsend): Fix check for nsmap
+       bounds.
+
 2014-12-16  Arjun Shankar  <arjun.is@lostca.se>
 
        * libio/tst-fopenloc.c: Use test-skeleton.c.
index 4a95eb80cb4d5c298b0e959732214e3bf8161ce6..5a9882c6ad51d4b2dee0ede5d0e6e2fcbccf7486 100644 (file)
@@ -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++;