summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2020-10-01 10:36:41 +0200
committerDmitry V. Levin <ldv@altlinux.org>2020-10-25 08:00:00 +0000
commitb303486bf1b812dd99f48a7bbb81838d658f7e03 (patch)
treea87b5097bc6fd3824ce4c159c2244bdd3a63bd39
parentef9983f9d45d42f5d8adaf59592517092586ec73 (diff)
downloadlinux-pam-git-b303486bf1b812dd99f48a7bbb81838d658f7e03.tar.gz
Add missing format function attributes and enable -Wmissing-format-attribute
Exported functions already have these attributes, add them to other functions. This enables compilers to find format specifier mismatches, like: foo_print("Hello %d", "world") * m4/warn_lang_flags.m4 (gl_WARN_ADD): Add -Wmissing-format-attribute. * conf/pam_conv1/Makefile.am (AM_CFLAGS): Add -I$(top_srcdir)/libpam/include. * conf/pam_conv1/pam_conv_y.y: Include <security/_pam_types.h>. (yyerror): Add printf format attribute. * modules/pam_pwhistory/opasswd.c (helper_log_err): Likewise. * modules/pam_rootok/pam_rootok.c (log_callback): Likewise. * modules/pam_tally/pam_tally.c (tally_log): Likewise. * modules/pam_tally2/pam_tally2.c (tally_log): Likewise. * modules/pam_unix/passverify.c (helper_log_err): Likewise.
-rw-r--r--conf/pam_conv1/Makefile.am2
-rw-r--r--conf/pam_conv1/pam_conv_y.y3
-rw-r--r--m4/warn_lang_flags.m41
-rw-r--r--modules/pam_pwhistory/opasswd.c1
-rw-r--r--modules/pam_rootok/pam_rootok.c1
-rw-r--r--modules/pam_tally/pam_tally.c1
-rw-r--r--modules/pam_tally2/pam_tally2.c1
-rw-r--r--modules/pam_unix/passverify.c1
8 files changed, 10 insertions, 1 deletions
diff --git a/conf/pam_conv1/Makefile.am b/conf/pam_conv1/Makefile.am
index 4c72162b..88993a20 100644
--- a/conf/pam_conv1/Makefile.am
+++ b/conf/pam_conv1/Makefile.am
@@ -8,7 +8,7 @@ EXTRA_DIST = README
AM_YFLAGS = -d
-AM_CFLAGS = $(WARN_CFLAGS)
+AM_CFLAGS = -I$(top_srcdir)/libpam/include $(WARN_CFLAGS)
pam_conv1_CFLAGS = $(AM_CFLAGS) -Wno-unused-function -Wno-sign-compare
diff --git a/conf/pam_conv1/pam_conv_y.y b/conf/pam_conv1/pam_conv_y.y
index c971abf4..66d80440 100644
--- a/conf/pam_conv1/pam_conv_y.y
+++ b/conf/pam_conv1/pam_conv_y.y
@@ -20,6 +20,8 @@
#include <ctype.h>
#include <sys/stat.h>
+#include <security/_pam_types.h>
+
extern int yylex(void);
int current_line=1;
@@ -184,6 +186,7 @@ const char *old_to_new_ctrl_flag(const char *old)
return clist[i];
}
+PAM_FORMAT((printf, 1, 2))
void yyerror(const char *format, ...)
{
va_list args;
diff --git a/m4/warn_lang_flags.m4 b/m4/warn_lang_flags.m4
index 740194f0..7c4871d6 100644
--- a/m4/warn_lang_flags.m4
+++ b/m4/warn_lang_flags.m4
@@ -11,6 +11,7 @@ gl_WARN_ADD([-Wdeprecated])
gl_WARN_ADD([-Winline])
gl_WARN_ADD([-Wmain])
gl_WARN_ADD([-Wmissing-declarations])
+gl_WARN_ADD([-Wmissing-format-attribute])
gl_WARN_ADD([-Wmissing-prototypes])
gl_WARN_ADD([-Wp64])
gl_WARN_ADD([-Wpointer-arith])
diff --git a/modules/pam_pwhistory/opasswd.c b/modules/pam_pwhistory/opasswd.c
index ac10f691..40296d59 100644
--- a/modules/pam_pwhistory/opasswd.c
+++ b/modules/pam_pwhistory/opasswd.c
@@ -89,6 +89,7 @@ typedef struct {
} opwd;
#ifdef HELPER_COMPILE
+PAM_FORMAT((printf, 2, 3))
void
helper_log_err(int err, const char *format, ...)
{
diff --git a/modules/pam_rootok/pam_rootok.c b/modules/pam_rootok/pam_rootok.c
index eb9c5eee..dd374c53 100644
--- a/modules/pam_rootok/pam_rootok.c
+++ b/modules/pam_rootok/pam_rootok.c
@@ -50,6 +50,7 @@ _pam_parse (const pam_handle_t *pamh, int argc, const char **argv)
#ifdef WITH_SELINUX
static int
+PAM_FORMAT((printf, 2, 3))
log_callback (int type UNUSED, const char *fmt, ...)
{
int audit_fd;
diff --git a/modules/pam_tally/pam_tally.c b/modules/pam_tally/pam_tally.c
index 34ae6241..6fd65009 100644
--- a/modules/pam_tally/pam_tally.c
+++ b/modules/pam_tally/pam_tally.c
@@ -94,6 +94,7 @@ struct tally_options {
#ifdef MAIN
#define pam_syslog tally_log
static void
+PAM_FORMAT((printf, 3, 4))
tally_log (const pam_handle_t *pamh UNUSED, int priority UNUSED,
const char *fmt, ...)
{
diff --git a/modules/pam_tally2/pam_tally2.c b/modules/pam_tally2/pam_tally2.c
index 117df699..bcf3188c 100644
--- a/modules/pam_tally2/pam_tally2.c
+++ b/modules/pam_tally2/pam_tally2.c
@@ -120,6 +120,7 @@ struct tally_options {
#ifdef MAIN
#define pam_syslog tally_log
static void
+PAM_FORMAT((printf, 3, 4))
tally_log (const pam_handle_t *pamh UNUSED, int priority UNUSED,
const char *fmt, ...)
{
diff --git a/modules/pam_unix/passverify.c b/modules/pam_unix/passverify.c
index c0fbc987..f6132f80 100644
--- a/modules/pam_unix/passverify.c
+++ b/modules/pam_unix/passverify.c
@@ -1117,6 +1117,7 @@ helper_verify_password(const char *name, const char *p, int nullok)
}
void
+PAM_FORMAT((printf, 2, 3))
helper_log_err(int err, const char *format, ...)
{
va_list args;