Message ID | 1499348109-8835-1-git-send-email-thuth@redhat.com |
---|---|
State | Accepted |
Headers | show |
Thomas Huth <thuth@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@redhat.com> Reviewed-by: Nikunj A Dadhania <nikunj@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@lists.ozlabs.org > https://lists.ozlabs.org/listinfo/slof
On 06/07/17 23:35, Thomas Huth wrote: > 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. > Thanks, applied. > Signed-off-by: Thomas Huth <thuth@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) > >
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)
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@redhat.com> --- lib/libnet/tftp.c | 2 +- make.rules | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)