Message ID | 20240411104340.6617-5-philmd@linaro.org |
---|---|
State | New |
Headers | show |
Series | misc: Replace sprintf() by snprintf() due to macOS deprecation | expand |
On Thu, 11 Apr 2024 at 11:44, Philippe Mathieu-Daudé <philmd@linaro.org> wrote: > > 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> > --- > 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..b0f04af4b6 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, sizeofbuf), "/lib/lib%d.so", id); Indentation has gone wrong, and another missing '('. Looking at that, I notice that this function is actually dead code -- it's in code that is only compiled and called if CONFIG_BINFMT_SHARED_FLAT is defined, and if you try to define that you will hit the "#error needs checking" in the calc_reloc() function. It seems to have been like this since the flatload support was added in 2006. So I think we should remove the dead code -- I'll send a patch. thanks -- PMM
diff --git a/linux-user/flatload.c b/linux-user/flatload.c index 5b62aa0a2b..b0f04af4b6 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, sizeofbuf), "/lib/lib%d.so", id); /* Open the file up */ bprm.filename = buf;
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> --- linux-user/flatload.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)