From: Richard Henderson Date: Thu, 6 May 1999 19:52:29 +0000 (+0000) Subject: * symbols.c (symbol_find_base): Use memcpy instead of strcpy. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=03987ceda10cf6d46476f5bd53be660c018e7d12;p=binutils-gdb.git * symbols.c (symbol_find_base): Use memcpy instead of strcpy. Don't copy before downcaseing. --- diff --git a/gas/ChangeLog b/gas/ChangeLog index 4acef717561..c5810e36181 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,8 @@ +Thu May 6 19:50:14 1999 Richard Henderson + + * symbols.c (symbol_find_base): Use memcpy instead of strcpy. + Don't copy before downcaseing. + 1999-05-05 Catherine Moore * tc-m68k.c: Include elf/m68k.h. diff --git a/gas/symbols.c b/gas/symbols.c index a1cde6a7de2..8a05e1f8c43 100644 --- a/gas/symbols.c +++ b/gas/symbols.c @@ -456,23 +456,30 @@ symbol_find_base (name, strip_underscore) #ifdef tc_canonicalize_symbol_name { char *copy; + size_t len = strlen (name) + 1; - copy = (char *) alloca (strlen (name) + 1); - strcpy (copy, name); + copy = (char *) alloca (len); + memcpy (copy, name, len); name = tc_canonicalize_symbol_name (copy); } #endif if (! symbols_case_sensitive) { - unsigned char *copy; - - copy = (unsigned char *) alloca (strlen (name) + 1); - strcpy (copy, name); - name = (const char *) copy; - for (; *copy != '\0'; copy++) - if (islower (*copy)) - *copy = toupper (*copy); + char *copy; + const char *orig; + unsigned char c; + + orig = name; + name = copy = (char *) alloca (strlen (name) + 1); + + while ((c = *orig++) != '\0') + { + if (islower (c)) + c = toupper (c); + *copy++ = c; + } + *copy = '\0'; } return ((symbolS *) hash_find (sy_hash, name));