From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25599 invoked by alias); 3 Feb 2003 06:32:13 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 25585 invoked from network); 3 Feb 2003 06:32:11 -0000 Received: from unknown (HELO dellpi.pinski.fam) (66.161.251.123) by 172.16.49.205 with SMTP; 3 Feb 2003 06:32:11 -0000 Received: from physics.uc.edu (IDENT:pinskia@localhost.pinski.fam [127.0.0.1]) by dellpi.pinski.fam (8.12.2/8.12.1) with ESMTP id h136W1MJ014429; Mon, 3 Feb 2003 01:32:03 -0500 (EST) Date: Mon, 03 Feb 2003 06:32:00 -0000 Subject: Re: [PATCH] Re: strcat and config/darwin.c Content-Type: multipart/mixed; boundary=Apple-Mail-9--625271574 Mime-Version: 1.0 (Apple Message framework v551) Cc: gcc-patches@gcc.gnu.org, gcc@gcc.gnu.org, apinski@apple.com To: Andrew Pinski From: Andrew Pinski In-Reply-To: <8BF8B765-3700-11D7-84EB-000393A6D2F2@physics.uc.edu> Message-Id: <33F50DFA-3741-11D7-84EB-000393A6D2F2@physics.uc.edu> X-SW-Source: 2003-02/txt/msg00060.txt.bz2 --Apple-Mail-9--625271574 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed Content-length: 142 I messed up the patch, in machopic_classify_ident, I forgot to add one to the length to copy the null character. Here is an updated patch: --Apple-Mail-9--625271574 Content-Disposition: attachment; filename=darwin.str.diff Content-Transfer-Encoding: 7bit Content-Type: application/octet-stream; x-unix-mode=0644; name="darwin.str.diff" Content-length: 2563 --- ../../../../gcc-clean/src/gcc/config/darwin.c Sat Jan 25 15:19:38 2003 +++ ./darwin.c Sun Feb 2 22:19:53 2003 @@ -124,8 +124,9 @@ machopic_classify_ident (ident) else if (name[1] == 'd' || name[1] == 't') { char *new_name; - new_name = (char *)alloca (strlen (name) + 1); - strcpy (new_name, name); + int name_len = strlen (name); + new_name = (char *)alloca (name_len + 1); + memcpy (new_name, name, name_len + 1); new_name[1] = (name[1] == 'd') ? 'D' : 'T'; if (maybe_get_identifier (new_name) != NULL) return (name[1] == 'd') ? MACHOPIC_DEFINED_DATA @@ -295,19 +296,24 @@ machopic_non_lazy_ptr_name (name) { char *buffer; tree ptr_name; + int len_name = strlen (name); - buffer = alloca (strlen (name) + 20); + buffer = alloca ( len_name + 20); - strcpy (buffer, "&L"); + memcpy (buffer, "&L", 2); if (name[0] == '*') - strcat (buffer, name+1); + { + memcpy (buffer + 2, name + 1, len_name); + len_name -= 1; + } else { - strcat (buffer, "_"); - strcat (buffer, name); + memcpy (buffer + 2, "_", 1); + memcpy (buffer + 3, name, len_name + 1); + len_name += 1; } - strcat (buffer, "$non_lazy_ptr"); + memcpy (buffer + 2 + len_name, "$non_lazy_ptr", strlen ("$non_lazy_ptr") + 1); ptr_name = get_identifier (buffer); machopic_non_lazy_pointers @@ -354,27 +360,37 @@ machopic_stub_name (name) char *buffer; tree ptr_name; int needs_quotes = name_needs_quotes (name); + int len=0; + int name_len = strlen (name); - buffer = alloca (strlen (name) + 20); + buffer = alloca (name_len + 20); if (needs_quotes) - strcpy (buffer, "&\"L"); + { + len = 3; + memcpy (buffer, "&\"L", len); + } else - strcpy (buffer, "&L"); + { + len = 2; + memcpy (buffer, "&L", len); + } if (name[0] == '*') { - strcat (buffer, name+1); + len += name_len-1; + memcpy (buffer+len, name+1, name_len); } else { - strcat (buffer, "_"); - strcat (buffer, name); + memcpy (buffer + len, "_", 1); + memcpy (buffer + len + 1, name, name_len); + len += name_len+1; } if (needs_quotes) - strcat (buffer, "$stub\""); + memcpy (buffer + len, "$stub\"", 7); else - strcat (buffer, "$stub"); + memcpy (buffer + len, "$stub", 6); ptr_name = get_identifier (buffer); machopic_stubs = tree_cons (ptr_name, ident, machopic_stubs); --Apple-Mail-9--625271574 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed Content-length: 575 Thanks, Andrew Pinski apinski@apple.com pinskia@physics.uc.edu On Sunday, Feb 2, 2003, at 14:49 US/Pacific, Andrew Pinski wrote: > Here is an updated with the suggestion from Richard Henderson by it > using memcpy instead of strcpy: > > 2003-02-02 Andrew Pinski > > * config/darwin.c: (machopic_non_lazy_ptr_name): Change strcat to > memcpy with length added. > (machopic_stub_name): Likewise. (machopic_classify_ident): Change > strcpy to memcpy. > > > Thanks, > Andrew Pinski > apinski@apple.com > pinskia@physics.uc.edu > --Apple-Mail-9--625271574--