ash: placate -Werror=format-security

"In function 'sprint_status48':
 error: format not a string literal and no format arguments"

function                                             old     new   delta
sprint_status48                                      160     158      -2

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2021-02-18 13:44:27 +01:00
parent 666a9a4c4d
commit 33745b1fc8
3 changed files with 21 additions and 3 deletions

View File

@ -407,6 +407,7 @@ typedef unsigned smalluint;
#define HAVE_SETBIT 1 #define HAVE_SETBIT 1
#define HAVE_SIGHANDLER_T 1 #define HAVE_SIGHANDLER_T 1
#define HAVE_STPCPY 1 #define HAVE_STPCPY 1
#define HAVE_STPNCPY 1
#define HAVE_MEMPCPY 1 #define HAVE_MEMPCPY 1
#define HAVE_STRCASESTR 1 #define HAVE_STRCASESTR 1
#define HAVE_STRCHRNUL 1 #define HAVE_STRCHRNUL 1
@ -442,6 +443,7 @@ typedef unsigned smalluint;
# undef HAVE_MKDTEMP # undef HAVE_MKDTEMP
# undef HAVE_SETBIT # undef HAVE_SETBIT
# undef HAVE_STPCPY # undef HAVE_STPCPY
# undef HAVE_STPNCPY
# undef HAVE_STRCASESTR # undef HAVE_STRCASESTR
# undef HAVE_STRCHRNUL # undef HAVE_STRCHRNUL
# undef HAVE_STRSEP # undef HAVE_STRSEP
@ -514,6 +516,7 @@ typedef unsigned smalluint;
#if defined(__digital__) && defined(__unix__) #if defined(__digital__) && defined(__unix__)
# undef HAVE_STPCPY # undef HAVE_STPCPY
# undef HAVE_STPNCPY
#endif #endif
#if defined(ANDROID) || defined(__ANDROID__) #if defined(ANDROID) || defined(__ANDROID__)
@ -530,6 +533,7 @@ typedef unsigned smalluint;
# undef HAVE_TTYNAME_R # undef HAVE_TTYNAME_R
# undef HAVE_GETLINE # undef HAVE_GETLINE
# undef HAVE_STPCPY # undef HAVE_STPCPY
# undef HAVE_STPNCPY
# endif # endif
# undef HAVE_MEMPCPY # undef HAVE_MEMPCPY
# undef HAVE_STRCHRNUL # undef HAVE_STRCHRNUL
@ -574,6 +578,10 @@ typedef void (*sighandler_t)(int);
extern char *stpcpy(char *p, const char *to_add) FAST_FUNC; extern char *stpcpy(char *p, const char *to_add) FAST_FUNC;
#endif #endif
#ifndef HAVE_STPNCPY
extern char *stpncpy(char *p, const char *to_add, size_t n) FAST_FUNC;
#endif
#ifndef HAVE_MEMPCPY #ifndef HAVE_MEMPCPY
#include <string.h> #include <string.h>
/* In case we are wrong about !HAVE_MEMPCPY, and toolchain _does_ have /* In case we are wrong about !HAVE_MEMPCPY, and toolchain _does_ have

View File

@ -166,6 +166,18 @@ char* FAST_FUNC stpcpy(char *p, const char *to_add)
} }
#endif #endif
#ifndef HAVE_STPNCPY
char* FAST_FUNC stpncpy(char *p, const char *to_add, size_t n)
{
while (n != 0 && (*p = *to_add) != '\0') {
p++;
to_add++;
n--;
}
return p;
}
#endif
#ifndef HAVE_GETLINE #ifndef HAVE_GETLINE
ssize_t FAST_FUNC getline(char **lineptr, size_t *n, FILE *stream) ssize_t FAST_FUNC getline(char **lineptr, size_t *n, FILE *stream)
{ {

View File

@ -4263,9 +4263,7 @@ sprint_status48(char *os, int status, int sigonly)
#endif #endif
} }
st &= 0x7f; st &= 0x7f;
//TODO: use bbox's get_signame? strsignal adds ~600 bytes to text+rodata s = stpncpy(s, strsignal(st), 32);
//s = stpncpy(s, strsignal(st), 32); //not all libc have stpncpy()
s += fmtstr(s, 32, strsignal(st));
if (WCOREDUMP(status)) { if (WCOREDUMP(status)) {
s = stpcpy(s, " (core dumped)"); s = stpcpy(s, " (core dumped)");
} }