[SLOF] [PATCH] libnet: Make the code compilable with -Wformat-security

Thomas Huth thuth at redhat.com
Thu Jul 6 23:35:09 AEST 2017


When compiling the libnet code with the -Wformat-security compiler
flag, there is a warning in tftp.c that printf is used without
format argument. It's not a real problem here, but let's make
the code ready for this compiler flag anyway and add a proper
format string here, too.

Signed-off-by: Thomas Huth <thuth at redhat.com>
---
 lib/libnet/tftp.c | 2 +-
 make.rules        | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/libnet/tftp.c b/lib/libnet/tftp.c
index ab63578..108092b 100644
--- a/lib/libnet/tftp.c
+++ b/lib/libnet/tftp.c
@@ -266,7 +266,7 @@ static void print_progress(int urgent, int received_bytes)
 			sprintf(buffer, "%d KBytes", (progress_last_bytes >> 10));
 			for(ptr = buffer; *ptr != 0; ++ptr)
 				*ptr = '\b';
-			printf(buffer);
+			printf("%s", buffer);
 		}
 		printf("%d KBytes", (received_bytes >> 10));
 		i = 1;
diff --git a/make.rules b/make.rules
index cbc6353..3067314 100644
--- a/make.rules
+++ b/make.rules
@@ -72,7 +72,7 @@ AR		?= $(CROSS)ar
 RANLIB		?= $(CROSS)ranlib
 CPP		?= $(CROSS)cpp
 
-WARNFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes
+WARNFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -Wformat-security
 CFLAGS ?= -g -O2 -fno-builtin -ffreestanding -nostdinc -msoft-float -fno-strict-aliasing \
 	  -mno-altivec -mabi=no-altivec -fno-stack-protector $(WARNFLAGS)
 
-- 
1.8.3.1



More information about the SLOF mailing list