From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4456 invoked by alias); 3 Mar 2011 22:04:13 -0000 Received: (qmail 4441 invoked by uid 22791); 3 Mar 2011 22:04:12 -0000 X-SWARE-Spam-Status: No, hits=-5.1 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp-outbound-1.vmware.com (HELO smtp-outbound-1.vmware.com) (65.115.85.69) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 03 Mar 2011 22:04:08 +0000 Received: from mailhost2.vmware.com (mailhost2.vmware.com [10.16.67.167]) by smtp-outbound-1.vmware.com (Postfix) with ESMTP id DAAD91305A; Thu, 3 Mar 2011 14:04:06 -0800 (PST) Received: from msnyder-server.eng.vmware.com (promd-2s-dhcp138.eng.vmware.com [10.20.124.138]) by mailhost2.vmware.com (Postfix) with ESMTP id D11038EE04; Thu, 3 Mar 2011 14:04:06 -0800 (PST) Message-ID: <4D701056.1080208@vmware.com> Date: Thu, 03 Mar 2011 22:04:00 -0000 From: Michael Snyder User-Agent: Thunderbird 2.0.0.24 (X11/20101201) MIME-Version: 1.0 To: "dj@redhat.com" , "gcc-patches@gcc.gnu.org" , "gdb-patches@sourceware.org" Subject: [RFA] libiberty/hashtab.c, higher_prime_index: avoid array overrun Content-Type: multipart/mixed; boundary="------------000606070100090304080904" X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-03/txt/msg00217.txt.bz2 This is a multi-part message in MIME format. --------------000606070100090304080904 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 79 As written, the function will access element [30] of a 30-element array. OK? --------------000606070100090304080904 Content-Type: text/plain; name="hashtab.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="hashtab.txt" Content-length: 764 2011-03-03 Michael Snyder * hashtab.c (higher_prime_index): Prevent array overrun. Index: hashtab.c =================================================================== RCS file: /cvs/src/src/libiberty/hashtab.c,v retrieving revision 1.38 diff -u -p -u -p -r1.38 hashtab.c --- hashtab.c 3 Feb 2011 07:23:59 -0000 1.38 +++ hashtab.c 3 Mar 2011 22:01:08 -0000 @@ -173,9 +173,9 @@ static unsigned int higher_prime_index (unsigned long n) { unsigned int low = 0; - unsigned int high = sizeof(prime_tab) / sizeof(prime_tab[0]); + unsigned int high = sizeof(prime_tab) / sizeof(prime_tab[0]) - 1; - while (low != high) + while (low < high) { unsigned int mid = low + (high - low) / 2; if (n > prime_tab[mid].prime) --------------000606070100090304080904--