This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] gcc/config/nios2/nios2.c: Let custom_builtin_name[*] always be zero terminated string
- From: Chung-Lin Tang <chunglin_tang at mentor dot com>
- To: Chen Gang <gang dot chen dot 5i5j at gmail dot com>, Jeff Law <law at redhat dot com>, <cltang at codesourcery dot com>, <sandra at codesourcery dot com>
- Cc: <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 26 Jul 2014 14:32:47 +0800
- Subject: Re: [PATCH] gcc/config/nios2/nios2.c: Let custom_builtin_name[*] always be zero terminated string
- Authentication-results: sourceware.org; auth=none
- References: <53D3205B dot 9050907 at gmail dot com>
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 <gang.chen.5i5j@gmail.com>
> ---
> 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)
>