linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs-progs: fix a printf format string fatal warning
@ 2019-07-13 23:14 Adam Borowski
  2019-07-22 12:44 ` David Sterba
  0 siblings, 1 reply; 2+ messages in thread
From: Adam Borowski @ 2019-07-13 23:14 UTC (permalink / raw)
  To: David Sterba, linux-btrfs; +Cc: Adam Borowski

At least in Debian, default build flags include -Werror=format-security,
for good reasons in most cases.  Here, the string comes from strftime --
and though I don't suspect any locale would be crazy enough to have %X
include a '%' char, the compiler has no way to know that.

Signed-off-by: Adam Borowski <kilobyte@angband.pl>
---
 common/format-output.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/format-output.c b/common/format-output.c
index c5f1b51f..98fb8607 100644
--- a/common/format-output.c
+++ b/common/format-output.c
@@ -280,7 +280,7 @@ void fmt_print(struct format_ctx *fctx, const char* key, ...)
 
 			localtime_r(&ts, &tm);
 			strftime(tstr, 256, "%Y-%m-%d %X %z", &tm);
-			printf(tstr);
+			printf("%s", tstr);
 		} else {
 			putchar('-');
 		}
-- 
2.22.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] btrfs-progs: fix a printf format string fatal warning
  2019-07-13 23:14 [PATCH] btrfs-progs: fix a printf format string fatal warning Adam Borowski
@ 2019-07-22 12:44 ` David Sterba
  0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2019-07-22 12:44 UTC (permalink / raw)
  To: Adam Borowski; +Cc: David Sterba, linux-btrfs

On Sun, Jul 14, 2019 at 01:14:54AM +0200, Adam Borowski wrote:
> At least in Debian, default build flags include -Werror=format-security,
> for good reasons in most cases.  Here, the string comes from strftime --
> and though I don't suspect any locale would be crazy enough to have %X
> include a '%' char, the compiler has no way to know that.
> 
> Signed-off-by: Adam Borowski <kilobyte@angband.pl>

Applied, thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-07-22 12:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-13 23:14 [PATCH] btrfs-progs: fix a printf format string fatal warning Adam Borowski
2019-07-22 12:44 ` David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).