All of
 help / color / mirror / Atom feed
From: Jeff King <>
Subject: [PATCH] add -Wformat-security
Date: Fri, 7 Sep 2018 14:19:05 -0400	[thread overview]
Message-ID: <> (raw)

We currently build cleanly with -Wformat-security, and it's
a good idea to make sure we continue to do so (since calls
that trigger the warning may be security vulnerabilities).

Note that we cannot use the stronger -Wformat-nonliteral, as
there are case where we are clever with passing around
pointers to string literals. E.g., bisect_rev_setup() takes
bad_format and good_format parameters. These ultimately come
from literals, but they still trigger the warning.

Some of these might be fixable (e.g., by passing flags from
which we locally select a format), and might even be worth
fixing (not because of security, but just because it's an
easy mistake to pass the wrong format). But there are other
cases which are likely quite hard to fix (we actually
generate formats in a local buffer in some cases). So let's
punt on that for now and start with -Wformat-security, which
is supposed to catch the most important cases.

Signed-off-by: Jeff King <>
--- | 1 +
 1 file changed, 1 insertion(+)

diff --git a/ b/
index 9a998149d9..f832752454 100644
--- a/
+++ b/
@@ -14,6 +14,7 @@ CFLAGS += -Wpointer-arith
 CFLAGS += -Wstrict-prototypes
 CFLAGS += -Wunused
 CFLAGS += -Wvla
+CFLAGS += -Wformat-security
 COMPILER_FEATURES := $(shell ./detect-compiler $(CC))

             reply	other threads:[~2018-09-07 18:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-07 18:19 Jeff King [this message]
2018-09-08 13:38 ` [PATCH] add -Wformat-security Duy Nguyen
2018-09-08 16:23   ` [PATCH v2] " Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.