PRINTF_FUNCTION -> ALMOST_PRINTF.
authorPhil Pennock <pdp@exim.org>
Sat, 19 May 2012 23:55:15 +0000 (19:55 -0400)
committerPhil Pennock <pdp@exim.org>
Sat, 19 May 2012 23:55:15 +0000 (19:55 -0400)
WANT_DEEPER_PRINTF_CHECKS guards ALMOST_PRINTF being PRINTF_FUNCTION.
Fix some actual issues exposed when I cut down on the spam.

doc/doc-txt/ChangeLog
src/src/config.h.defaults
src/src/deliver.c
src/src/expand.c
src/src/functions.h
src/src/local_scan.h
src/src/malware.c
src/src/mytypes.h
src/src/spool_mbox.c
src/src/string.c

index 620d871143742c696e204eea8fe188a1e7b22293..21f1ec747a5c0554cd55437ce19b7ae812f7eddd 100644 (file)
@@ -129,6 +129,11 @@ PP/29 Fix three issues highlighted by clang analyser static analysis.
 
 PP/30 Another attempt to deal with PCRE_PRERELEASE, this one less buggy.
 
+PP/31 %D in printf continues to cause issues (-Wformat=security), so for
+      now guard some of the printf checks behind WANT_DEEPER_PRINTF_CHECKS.
+      As part of this, removing so much warning spew let me fix some minor
+      real issues in debug logging.
+
 
 Exim version 4.77
 -----------------
index 1e75a1e217a39ca7a7797fc81443c415a1c8a199..92a4cd348373f9deb014704bb882f01eaa459ead 100644 (file)
@@ -167,6 +167,9 @@ it's a default value. */
 #define EXPERIMENTAL_SPF
 #define EXPERIMENTAL_SRS
 
+/* For developers */
+#define WANT_DEEPER_PRINTF_CHECKS
+
 /* Things that are not routinely changed but are nevertheless configurable
 just in case. */
 
index 10b63397efdadad24bdad409e2562c146b1c6888..d4ea2d868c2d45916a1048985c982f432b9107d6 100644 (file)
@@ -1213,7 +1213,7 @@ if (format != NULL)
   va_start(ap, format);
   if (!string_vformat(buffer, sizeof(buffer), CS format, ap))
     log_write(0, LOG_MAIN|LOG_PANIC_DIE,
-      "common_error expansion was longer than %d", sizeof(buffer));
+      "common_error expansion was longer than " SIZE_T_FMT, sizeof(buffer));
   va_end(ap);
   addr->message = string_copy(buffer);
   }
index 70fb32c5e3dd110afd060ee1320fe12b6da81179..84167b688d60c756ac0eac726622e7c7c99963b8 100644 (file)
@@ -1527,8 +1527,8 @@ while (last > first)
     domain = Ustrrchr(s, '@');
     if (domain == NULL) return s;
     if (domain - s > sizeof(var_buffer) - 1)
-      log_write(0, LOG_MAIN|LOG_PANIC_DIE, "local part longer than %d in "
-        "string expansion", sizeof(var_buffer));
+      log_write(0, LOG_MAIN|LOG_PANIC_DIE, "local part longer than " SIZE_T_FMT
+          " in string expansion", sizeof(var_buffer));
     Ustrncpy(var_buffer, s, domain - s);
     var_buffer[domain - s] = 0;
     return var_buffer;
index 78f095adc85beaa734ae0ff279b6c9eae1986925..cf8c54fe9e8fa79ddb5848e9b7d00063a5c31115 100644 (file)
@@ -325,7 +325,7 @@ extern uschar *string_copy_malloc(uschar *);
 extern uschar *string_copylc(uschar *);
 extern uschar *string_copynlc(uschar *, int);
 extern uschar *string_dequote(uschar **);
-extern BOOL    string_format(uschar *, int, const char *, ...) PRINTF_FUNCTION(3,4);
+extern BOOL    string_format(uschar *, int, const char *, ...) ALMOST_PRINTF(3,4);
 extern uschar *string_format_size(int, uschar *);
 extern int     string_interpret_escape(uschar **);
 extern int     string_is_ip_address(uschar *, int *);
index 19350bf41540b7285e5fccce1f0d1629a1f1ef4c..057e4d428868f27d6ef18aba22241a9d994d5828 100644 (file)
@@ -188,6 +188,6 @@ extern void    smtp_printf(const char *, ...) PRINTF_FUNCTION(1,2);
 extern void    smtp_vprintf(const char *, va_list);
 extern uschar *string_copy(const uschar *);
 extern uschar *string_copyn(uschar *, int);
-extern uschar *string_sprintf(const char *, ...) PRINTF_FUNCTION(1,2);
+extern uschar *string_sprintf(const char *, ...) ALMOST_PRINTF(1,2);
 
 /* End of local_scan.h */
index 8906654839b2b505484e5b9a8983ab9092608954..7de913f49489ac6223b2bd5eda44371563c685ab 100644 (file)
@@ -1074,7 +1074,7 @@ static int malware_internal(uschar **listptr, uschar *eml_filename, BOOL faking)
       cmdline_trigger_re = pcre_compile(CS cmdline_trigger, PCRE_COPT, (const char **)&rerror, &roffset, NULL);
       if (cmdline_trigger_re == NULL) {
         log_write(0, LOG_MAIN|LOG_PANIC,
-                 "malware acl condition: regular expression error in '%s': %s at offset %d", cmdline_trigger_re, rerror, roffset);
+                 "malware acl condition: regular expression error in '%s': %s at offset %d", cmdline_trigger, rerror, roffset);
         return DEFER;
       };
 
@@ -1092,7 +1092,7 @@ static int malware_internal(uschar **listptr, uschar *eml_filename, BOOL faking)
       cmdline_regex_re = pcre_compile(CS cmdline_regex, PCRE_COPT, (const char **)&rerror, &roffset, NULL);
       if (cmdline_regex_re == NULL) {
         log_write(0, LOG_MAIN|LOG_PANIC,
-                 "malware acl condition: regular expression error in '%s': %s at offset %d", cmdline_regex_re, rerror, roffset);
+                 "malware acl condition: regular expression error in '%s': %s at offset %d", cmdline_regex, rerror, roffset);
         return DEFER;
       };
 
index f8a738da6f620ee6cf2af6eea7afc68a26b3050c..964abf820d92a3009208dc0e2a00aca231f86117 100644 (file)
@@ -37,6 +37,12 @@ the arguments of printf-like functions. This is done by a macro. */
 #define ARG_UNUSED  /**/
 #endif
 
+#ifdef WANT_DEEPER_PRINTF_CHECKS
+#define ALMOST_PRINTF(A, B) PRINTF_FUNCTION(A, B)
+#else
+#define ALMOST_PRINTF(A, B)
+#endif
+
 
 /* Some operating systems (naughtily, imo) include a definition for "uchar" in
 the standard header files, so we use "uschar". Solaris has u_char in
index 635fb8df1c4085150f7d5b51f0d55920154b3e60..bdeb2b1a66fea44eb5626cadf42b84796b00611d 100644 (file)
@@ -56,7 +56,7 @@ FILE *spool_mbox(unsigned long *mbox_file_size, uschar *source_file_override) {
     mbox_file = modefopen(mbox_path, "wb", SPOOL_MODE);
     if (mbox_file == NULL) {
       log_write(0, LOG_MAIN|LOG_PANIC, "%s", string_open_failed(errno,
-        "scan file %s", mbox_file));
+        "scan file %s", mbox_path));
       goto OUT;
     };
 
@@ -155,7 +155,7 @@ FILE *spool_mbox(unsigned long *mbox_file_size, uschar *source_file_override) {
   if (Ustat(mbox_path, &statbuf) != 0 ||
       (yield = Ufopen(mbox_path,"rb")) == NULL) {
     log_write(0, LOG_MAIN|LOG_PANIC, "%s", string_open_failed(errno,
-      "scan file %s", mbox_file));
+      "scan file %s", mbox_path));
     goto OUT;
   };
 
index 9764d3e38a464593161ab4091cc73639436c1264..08e6045942b721f668704920c2563e863743f5b3 100644 (file)
@@ -716,7 +716,7 @@ uschar buffer[STRING_SPRINTF_BUFFER_SIZE];
 va_start(ap, format);
 if (!string_vformat(buffer, sizeof(buffer), format, ap))
   log_write(0, LOG_MAIN|LOG_PANIC_DIE,
-    "string_sprintf expansion was longer than %d", sizeof(buffer));
+    "string_sprintf expansion was longer than " SIZE_T_FMT, sizeof(buffer));
 va_end(ap);
 return string_copy(buffer);
 }