Hello.
I get reports from people seeing "vfprintf %s NULL" in their logs
recently. The problem is in a function that should be fixed,
but that function is only expected to but used for debug traces.
This diff turns log_trace() into a macro, so the parameters
are not needlessly evaluated when tracing is not set.
Eric.
Index: smtpd.h
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/smtpd.h,v
retrieving revision 1.662
diff -u -p -r1.662 smtpd.h
--- smtpd.h 5 Mar 2021 12:37:32 -0000 1.662
+++ smtpd.h 23 Mar 2021 07:16:39 -0000
@@ -1747,8 +1747,9 @@ int base64_encode_rfc3548(unsigned char
char *, size_t);
void log_trace_verbose(int);
-void log_trace(int, const char *, ...)
- __attribute__((format (printf, 2, 3)));
+void log_trace0(const char *, ...)
+ __attribute__((format (printf, 1, 2)));
+#define log_trace(m, ...) do { if (tracing & (m)) log_trace0(__VA_ARGS__); }
while (0)
/* waitq.c */
int waitq_wait(void *, void (*)(void *, void *, void *), void *);
Index: util.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/util.c,v
retrieving revision 1.152
diff -u -p -r1.152 util.c
--- util.c 29 Nov 2020 20:07:38 -0000 1.152
+++ util.c 23 Mar 2021 07:17:05 -0000
@@ -823,15 +823,13 @@ base64_encode_rfc3548(unsigned char cons
}
void
-log_trace(int mask, const char *emsg, ...)
+log_trace0(const char *emsg, ...)
{
va_list ap;
- if (tracing & mask) {
- va_start(ap, emsg);
- vlog(LOG_DEBUG, emsg, ap);
- va_end(ap);
- }
+ va_start(ap, emsg);
+ vlog(LOG_DEBUG, emsg, ap);
+ va_end(ap);
}
void