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

Nikunj A Dadhania nikunj at linux.vnet.ibm.com
Fri Jul 7 14:39:01 AEST 2017


Thomas Huth <thuth at redhat.com> writes:

> 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>

Reviewed-by: Nikunj A Dadhania <nikunj at linux.vnet.ibm.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
>
> _______________________________________________
> SLOF mailing list
> SLOF at lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/slof



More information about the SLOF mailing list