Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [day] [month] [year] [list]
Date: Sun, 22 Nov 2015 15:12:00 +0100
From: Hauke Mehrtens <>
Cc: Hauke Mehrtens <>
Subject: [RFC] Add format attribute to syslog functions

GCC and Clang are able to check the format arguments given to a
function and warn the user if there is a error in the format arguments
or if there is a potential uncontrolled format string security problem
in the code. GCC does this automatically for some functions like
printf(), but it is also possible to annotate other functions in a way
that it will check them too. This feature is used by glibc for many
functions. This patch adds it to the syslog functions in musl, but it
could probably be added to more functions in musl.

The documentation from gcc is here:

The documentation from Clang is here:

Signed-off-by: Hauke Mehrtens <>
 include/syslog.h | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/include/syslog.h b/include/syslog.h
index 5b4d296..56cdaaf 100644
--- a/include/syslog.h
+++ b/include/syslog.h
@@ -59,13 +59,21 @@ extern "C" {
 void closelog (void);
 void openlog (const char *, int, int);
 int setlogmask (int);
-void syslog (int, const char *, ...);
+void syslog (int, const char *, ...)
+#if __GNUC__ >= 3
+__attribute__ ((format (printf, 2, 3)))
 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
 #define _PATH_LOG "/dev/log"
 #define __NEED_va_list
 #include <bits/alltypes.h>
-void vsyslog (int, const char *, va_list);
+void vsyslog (int, const char *, va_list)
+#if __GNUC__ >= 3
+__attribute__ ((format (printf, 2, 0)))
 #if defined(SYSLOG_NAMES)
 #define	INTERNAL_NOPRI 0x10

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.