Skip to content

Commit

Permalink
fix: shell quote user-provided mailer path
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiud committed Dec 21, 2023
1 parent 6607b36 commit 7012a7a
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/logging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2292,13 +2292,17 @@ static bool SendEmailInternal(const char*dest, const char *subject,
subject, body, dest);
}

string logmailer = FLAGS_logmailer;
if (logmailer.empty()) {
logmailer = "/bin/mail";
string logmailer;

if (FLAGS_logmailer.empty()) {
// Don't need to shell escape the literal string
logmailer = "/bin/mail";
} else {
logmailer = ShellEscape(FLAGS_logmailer);
}

string cmd =
logmailer + " -s" +
ShellEscape(subject) + " " + ShellEscape(dest);
logmailer + " -s" + ShellEscape(subject) + " " + ShellEscape(dest);
if (use_logging) {
VLOG(4) << "Mailing command: " << cmd;
}
Expand Down

0 comments on commit 7012a7a

Please sign in to comment.