config.mak.dev: add -Wformat-security
authorJeff King <peff@peff.net>
Sat, 8 Sep 2018 16:23:31 +0000 (12:23 -0400)
committerJunio C Hamano <gitster@pobox.com>
Tue, 11 Sep 2018 19:50:21 +0000 (12:50 -0700)
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 <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
config.mak.dev
index 2d244ca470d8d99f54034b1494127db25c5161ad..bfbd3df4e8ad51e6a86c5a6b9a953e0a70b0480d 100644 (file)
@@ -2,6 +2,7 @@ ifeq ($(filter no-error,$(DEVOPTS)),)
 CFLAGS += -Werror
 endif
 CFLAGS += -Wdeclaration-after-statement
+CFLAGS += -Wformat-security
 CFLAGS += -Wno-format-zero-length
 CFLAGS += -Wold-style-definition
 CFLAGS += -Woverflow