[PATCH] CSKY: Fix sprintf argument overlaping destination error.

Simon Marchi simon.marchi@efficios.com
Wed Sep 9 14:51:06 GMT 2020
On 2020-09-09 10:44 a.m., Cooper Qu wrote:
> Fix failure when building with gcc-10.
> 
> opcodes/
> 	* csky-dis.c (csky_output_operand): Fix sprintf argument
> 	overlaping destination error.
> 
> ---
>  opcodes/ChangeLog  | 5 +++++
>  opcodes/csky-dis.c | 6 ++++--
>  2 files changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
> index bd5a284949d..50dcf68a2ac 100644
> --- a/opcodes/ChangeLog
> +++ b/opcodes/ChangeLog
> @@ -1,3 +1,8 @@
> +2020-09-09  Cooper Qu  <cooper.qu@linux.alibaba.com>
> +
> +	* csky-dis.c (csky_output_operand): Fix sprintf argument
> +	overlaping destination error.
> +
>  2020-09-07  Cooper Qu  <cooper.qu@linux.alibaba.com>
>  
>  	* csky-opc.h (csky_v2_opcodes): Change mvtc and mulsw's
> diff --git a/opcodes/csky-dis.c b/opcodes/csky-dis.c
> index 89f1c6bcb3d..f18c53bbeb5 100644
> --- a/opcodes/csky-dis.c
> +++ b/opcodes/csky-dis.c
> @@ -647,7 +647,8 @@ csky_output_operand (char *str, struct operand const *oprnd,
>  
>  	float f = 0;
>  	memcpy (&f, &value, sizeof (float));
> -	sprintf (str, "%s%f\t// imm9:%4d, imm4:%2d", str, f, imm8, imm4);
> +	sprintf (buf, "%f\t// imm9:%4d, imm4:%2d", f, imm8, imm4);
> +	strcat (str, buf);
>  
>  	break;
>        }
> @@ -675,7 +676,8 @@ csky_output_operand (char *str, struct operand const *oprnd,
>  	  }
>  	double d = 0;
>  	memcpy (&d, &dvalue, sizeof (double));
> -	sprintf (str, "%s%lf\t// imm9:%4ld, imm4:%2ld", str, d, imm8, imm4);
> +	sprintf (buf, "%lf\t// imm9:%4ld, imm4:%2ld", d, imm8, imm4);
> +	strcat (str, buf);
>  
>  	break;
>        }
> -- 
> 2.26.2
> 

Thanks, that fixes it for me (though I can't tell if the code does the right thing,
I don't know this code).

I'd suggest adding a copy paste of the compilation failure in the commit message, that
helps later when trying to find which commit fixed which failure.

Simon


More information about the Binutils mailing list