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.
This commit is contained in:
Siddhesh Poyarekar 2014-12-16 16:53:05 +05:30
parent 8b460906cd
commit a0d424ef9d
2 changed files with 6 additions and 1 deletions

View File

@ -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.

View 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++;