From patchwork Tue Dec 16 10:09:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 4272 Received: (qmail 14389 invoked by alias); 16 Dec 2014 10:09:57 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 14379 invoked by uid 89); 16 Dec 2014 10:09:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Date: Tue, 16 Dec 2014 15:39:50 +0530 From: Siddhesh Poyarekar To: libc-alpha@sourceware.org Subject: [PATCH] Fix 'array subscript is above array bounds' warning in res_send.c Message-ID: <20141216100950.GM30928@spoyarek.pnq.redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.22.1-rc1 (2013-10-16) Hi, 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. OK to commit? Siddhesh * resolv/res_send.c (__libc_res_nsend): Fix check for nsmap bounds. 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++;