aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2021-02-18 13:44:27 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2021-02-18 13:45:49 +0100
commit33745b1fc8cc6d41f4e708d67800d296668af2ce (patch)
tree613c65a05046c60cdd0f786434c2c55b2e2e8d1b
parent666a9a4c4d90c70e91272e72dcf3592410f1b5d0 (diff)
downloadbusybox-w32-33745b1fc8cc6d41f4e708d67800d296668af2ce.tar.gz
busybox-w32-33745b1fc8cc6d41f4e708d67800d296668af2ce.tar.bz2
busybox-w32-33745b1fc8cc6d41f4e708d67800d296668af2ce.zip
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>
-rw-r--r--include/platform.h8
-rw-r--r--libbb/platform.c12
-rw-r--r--shell/ash.c4
3 files changed, 21 insertions, 3 deletions
diff --git a/include/platform.h b/include/platform.h
index d991f3140..24efd186b 100644
--- a/include/platform.h
+++ b/include/platform.h
@@ -407,6 +407,7 @@ typedef unsigned smalluint;
407#define HAVE_SETBIT 1 407#define HAVE_SETBIT 1
408#define HAVE_SIGHANDLER_T 1 408#define HAVE_SIGHANDLER_T 1
409#define HAVE_STPCPY 1 409#define HAVE_STPCPY 1
410#define HAVE_STPNCPY 1
410#define HAVE_MEMPCPY 1 411#define HAVE_MEMPCPY 1
411#define HAVE_STRCASESTR 1 412#define HAVE_STRCASESTR 1
412#define HAVE_STRCHRNUL 1 413#define HAVE_STRCHRNUL 1
@@ -442,6 +443,7 @@ typedef unsigned smalluint;
442# undef HAVE_MKDTEMP 443# undef HAVE_MKDTEMP
443# undef HAVE_SETBIT 444# undef HAVE_SETBIT
444# undef HAVE_STPCPY 445# undef HAVE_STPCPY
446# undef HAVE_STPNCPY
445# undef HAVE_STRCASESTR 447# undef HAVE_STRCASESTR
446# undef HAVE_STRCHRNUL 448# undef HAVE_STRCHRNUL
447# undef HAVE_STRSEP 449# undef HAVE_STRSEP
@@ -514,6 +516,7 @@ typedef unsigned smalluint;
514 516
515#if defined(__digital__) && defined(__unix__) 517#if defined(__digital__) && defined(__unix__)
516# undef HAVE_STPCPY 518# undef HAVE_STPCPY
519# undef HAVE_STPNCPY
517#endif 520#endif
518 521
519#if defined(ANDROID) || defined(__ANDROID__) 522#if defined(ANDROID) || defined(__ANDROID__)
@@ -530,6 +533,7 @@ typedef unsigned smalluint;
530# undef HAVE_TTYNAME_R 533# undef HAVE_TTYNAME_R
531# undef HAVE_GETLINE 534# undef HAVE_GETLINE
532# undef HAVE_STPCPY 535# undef HAVE_STPCPY
536# undef HAVE_STPNCPY
533# endif 537# endif
534# undef HAVE_MEMPCPY 538# undef HAVE_MEMPCPY
535# undef HAVE_STRCHRNUL 539# undef HAVE_STRCHRNUL
@@ -574,6 +578,10 @@ typedef void (*sighandler_t)(int);
574extern char *stpcpy(char *p, const char *to_add) FAST_FUNC; 578extern char *stpcpy(char *p, const char *to_add) FAST_FUNC;
575#endif 579#endif
576 580
581#ifndef HAVE_STPNCPY
582extern char *stpncpy(char *p, const char *to_add, size_t n) FAST_FUNC;
583#endif
584
577#ifndef HAVE_MEMPCPY 585#ifndef HAVE_MEMPCPY
578#include <string.h> 586#include <string.h>
579/* In case we are wrong about !HAVE_MEMPCPY, and toolchain _does_ have 587/* In case we are wrong about !HAVE_MEMPCPY, and toolchain _does_ have
diff --git a/libbb/platform.c b/libbb/platform.c
index 329b0237e..7913353e2 100644
--- a/libbb/platform.c
+++ b/libbb/platform.c
@@ -166,6 +166,18 @@ char* FAST_FUNC stpcpy(char *p, const char *to_add)
166} 166}
167#endif 167#endif
168 168
169#ifndef HAVE_STPNCPY
170char* FAST_FUNC stpncpy(char *p, const char *to_add, size_t n)
171{
172 while (n != 0 && (*p = *to_add) != '\0') {
173 p++;
174 to_add++;
175 n--;
176 }
177 return p;
178}
179#endif
180
169#ifndef HAVE_GETLINE 181#ifndef HAVE_GETLINE
170ssize_t FAST_FUNC getline(char **lineptr, size_t *n, FILE *stream) 182ssize_t FAST_FUNC getline(char **lineptr, size_t *n, FILE *stream)
171{ 183{
diff --git a/shell/ash.c b/shell/ash.c
index 1aead6df4..6a16833b1 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -4263,9 +4263,7 @@ sprint_status48(char *os, int status, int sigonly)
4263#endif 4263#endif
4264 } 4264 }
4265 st &= 0x7f; 4265 st &= 0x7f;
4266//TODO: use bbox's get_signame? strsignal adds ~600 bytes to text+rodata 4266 s = stpncpy(s, strsignal(st), 32);
4267 //s = stpncpy(s, strsignal(st), 32); //not all libc have stpncpy()
4268 s += fmtstr(s, 32, strsignal(st));
4269 if (WCOREDUMP(status)) { 4267 if (WCOREDUMP(status)) {
4270 s = stpcpy(s, " (core dumped)"); 4268 s = stpcpy(s, " (core dumped)");
4271 } 4269 }