diff mbox series

[v3,22/27] linux-user/flatload: Replace sprintf() by snprintf()

Message ID 20240412073346.458116-23-richard.henderson@linaro.org
State New
Headers show
Series misc: Replace sprintf | expand

Commit Message

Richard Henderson April 12, 2024, 7:33 a.m. UTC
From: Philippe Mathieu-Daudé <philmd@linaro.org>

sprintf() is deprecated on Darwin since macOS 13.0 / XCode 14.1,
resulting in painful developper experience. Use snprintf() instead.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20240411104340.6617-5-philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/flatload.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Peter Maydell April 12, 2024, 9:48 a.m. UTC | #1
On Fri, 12 Apr 2024 at 08:36, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
>
> sprintf() is deprecated on Darwin since macOS 13.0 / XCode 14.1,
> resulting in painful developper experience. Use snprintf() instead.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Message-Id: <20240411104340.6617-5-philmd@linaro.org>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Rather than this, I think we should use my patch which
drops this dead code entirely:

https://patchew.org/QEMU/20240411115313.680433-1-peter.maydell@linaro.org/

-- PMM
Pierrick Bouvier June 3, 2024, 7:02 p.m. UTC | #2
On 4/12/24 00:33, Richard Henderson wrote:
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> 
> sprintf() is deprecated on Darwin since macOS 13.0 / XCode 14.1,
> resulting in painful developper experience. Use snprintf() instead.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Message-Id: <20240411104340.6617-5-philmd@linaro.org>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   linux-user/flatload.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/linux-user/flatload.c b/linux-user/flatload.c
> index 5b62aa0a2b..1bb2f400bc 100644
> --- a/linux-user/flatload.c
> +++ b/linux-user/flatload.c
> @@ -692,7 +692,7 @@ static int load_flat_shared_library(int id, struct lib_info *libs)
>   	char buf[16];
>   
>   	/* Create the file name */
> -	sprintf(buf, "/lib/lib%d.so", id);
> +        snprintf(buf, sizeof(buf), "/lib/lib%d.so", id);
>   
>   	/* Open the file up */
>   	bprm.filename = buf;

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
diff mbox series

Patch

diff --git a/linux-user/flatload.c b/linux-user/flatload.c
index 5b62aa0a2b..1bb2f400bc 100644
--- a/linux-user/flatload.c
+++ b/linux-user/flatload.c
@@ -692,7 +692,7 @@  static int load_flat_shared_library(int id, struct lib_info *libs)
 	char buf[16];
 
 	/* Create the file name */
-	sprintf(buf, "/lib/lib%d.so", id);
+        snprintf(buf, sizeof(buf), "/lib/lib%d.so", id);
 
 	/* Open the file up */
 	bprm.filename = buf;