diff mbox series

[03/12] policycoreutils: use string literal as format strings

Message ID 20211112154201.78217-3-cgzones@googlemail.com (mailing list archive)
State Accepted
Headers show
Series [01/12] checkpolicy: use correct unsigned format specifiers | expand

Commit Message

Christian Göttsche Nov. 12, 2021, 3:41 p.m. UTC
Use string literal as format string so that compilers can validate the
count and types of the inherent arguments.

    sestatus.c: In function ‘printf_tab’:
    sestatus.c:175:16: error: format not a string literal, argument types not checked [-Werror=format-nonliteral]
      175 |         printf(buf, outp);
          |                ^~~

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
 policycoreutils/sestatus/sestatus.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/policycoreutils/sestatus/sestatus.c b/policycoreutils/sestatus/sestatus.c
index ceee0d52..538c73bc 100644
--- a/policycoreutils/sestatus/sestatus.c
+++ b/policycoreutils/sestatus/sestatus.c
@@ -170,9 +170,7 @@  void load_checks(char *pc[], int *npc, char *fc[], int *nfc)
 
 void printf_tab(const char *outp)
 {
-	char buf[20];
-	snprintf(buf, sizeof(buf), "%%-%us", COL);
-	printf(buf, outp);
+	printf("%-*s", COL, outp);
 
 }