btrfs-progs: fix a printf format string fatal warning
diff mbox series

Message ID 20190713231454.45129-1-kilobyte@angband.pl
State New
Headers show
Series
  • btrfs-progs: fix a printf format string fatal warning
Related show

Commit Message

Adam Borowski July 13, 2019, 11:14 p.m. UTC
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(-)

Comments

David Sterba July 22, 2019, 12:44 p.m. UTC | #1
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.

Patch
diff mbox series

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('-');
 		}