send_mail: pass a single string instead of using varargs

These days we only ever pass in a const string.
This commit is contained in:
Todd C. Miller
2023-02-09 11:09:03 -07:00
parent 2e1a73502e
commit b6caacfe4e

View File

@@ -350,7 +350,7 @@ exec_mailer(int pipein)
/* Send a message to the mailto user */ /* Send a message to the mailto user */
static bool static bool
send_mail(const struct eventlog *evlog, const char *fmt, ...) send_mail(const struct eventlog *evlog, const char *message)
{ {
const struct eventlog_config *evl_conf = eventlog_getconf(); const struct eventlog_config *evl_conf = eventlog_getconf();
const char *cp, *timefmt = evl_conf->time_fmt; const char *cp, *timefmt = evl_conf->time_fmt;
@@ -363,7 +363,6 @@ send_mail(const struct eventlog *evlog, const char *fmt, ...)
int fd, len, pfd[2], status; int fd, len, pfd[2], status;
pid_t pid, rv; pid_t pid, rv;
struct stat sb; struct stat sb;
va_list ap;
#if defined(HAVE_NL_LANGINFO) && defined(CODESET) #if defined(HAVE_NL_LANGINFO) && defined(CODESET)
char *locale; char *locale;
#endif #endif
@@ -537,9 +536,7 @@ send_mail(const struct eventlog *evlog, const char *fmt, ...)
} else { } else {
(void) fprintf(mail, "\n\n%s : ", timebuf); (void) fprintf(mail, "\n\n%s : ", timebuf);
} }
va_start(ap, fmt); fputs(message, mail);
(void) vfprintf(mail, fmt, ap);
va_end(ap);
fputs("\n\n", mail); fputs("\n\n", mail);
fclose(mail); fclose(mail);
@@ -1039,7 +1036,7 @@ do_syslog(int event_type, int flags, struct eventlog_args *args,
goto done; goto done;
if (ISSET(flags, EVLOG_MAIL)) { if (ISSET(flags, EVLOG_MAIL)) {
if (!send_mail(evlog, "%s", lbuf.buf)) { if (!send_mail(evlog, lbuf.buf)) {
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO, sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
"unable to mail log line"); "unable to mail log line");
} }
@@ -1224,7 +1221,7 @@ do_logfile(int event_type, int flags, struct eventlog_args *args,
goto done; goto done;
if (ISSET(flags, EVLOG_MAIL)) { if (ISSET(flags, EVLOG_MAIL)) {
if (!send_mail(evlog, "%s", lbuf.buf)) { if (!send_mail(evlog, lbuf.buf)) {
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO, sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
"unable to mail log line"); "unable to mail log line");
} }