From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1913 invoked by alias); 26 Jul 2014 06:33:00 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 1894 invoked by uid 89); 26 Jul 2014 06:32:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 26 Jul 2014 06:32:56 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1XAvXH-0000Gl-EP from ChungLin_Tang@mentor.com ; Fri, 25 Jul 2014 23:32:51 -0700 Received: from SVR-ORW-FEM-04.mgc.mentorg.com ([147.34.97.41]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Fri, 25 Jul 2014 23:32:51 -0700 Received: from air.local (147.34.91.1) by svr-orw-fem-04.mgc.mentorg.com (147.34.97.41) with Microsoft SMTP Server id 14.2.247.3; Fri, 25 Jul 2014 23:32:52 -0700 Message-ID: <53D34B8F.4080301@mentor.com> Date: Sat, 26 Jul 2014 07:04:00 -0000 From: Chung-Lin Tang User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: Chen Gang , Jeff Law , , CC: Subject: Re: [PATCH] gcc/config/nios2/nios2.c: Let custom_builtin_name[*] always be zero terminated string References: <53D3205B.9050907@gmail.com> In-Reply-To: <53D3205B.9050907@gmail.com> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-SW-Source: 2014-07/txt/msg01779.txt.bz2 On 14/7/26 11:28 AM, Chen Gang wrote: > The related strncpy() for custom_builtin_name[*] may set 5 none-zero > characters, which may cause custom_builtin_name[*] is none-zero > terminated. > > So add additional '\0' byte for custom_builtin_name[*]. Where did you see this? Supposedly the snprintf of the custom function type string should at most be of 'xnxx' format; 4 characters at most, not 5. Do you have a test case where the behavior you described appears? Thanks, Chung-Lin > ChangeLog: > > * config/nios2/nios2.c (custom_builtin_name): Let it always be > zero terminated string. > > Signed-off-by: Chen Gang > --- > gcc/config/nios2/nios2.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/gcc/config/nios2/nios2.c b/gcc/config/nios2/nios2.c > index a4e60c6..e4e005b 100644 > --- a/gcc/config/nios2/nios2.c > +++ b/gcc/config/nios2/nios2.c > @@ -2510,7 +2510,7 @@ nios2_expand_fpu_builtin (tree exp, unsigned int code, rtx target) > total of (3 + 1) * (1 + 3 + 9) == 52 custom builtin functions. > */ > #define NUM_CUSTOM_BUILTINS ((3 + 1) * (1 + 3 + 9)) > -static char custom_builtin_name[NUM_CUSTOM_BUILTINS][5]; > +static char custom_builtin_name[NUM_CUSTOM_BUILTINS][6]; > > static void > nios2_init_custom_builtins (int start_code) >