fix: shell quote user-provided mailer path (#999)

This commit is contained in:
Sergiu Deitsch 2023-12-21 19:54:07 +01:00 committed by GitHub
parent 716be9edc7
commit d937c2e1b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;
}