summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2003-08-27 23:53:15 +0000
committerIlia Alshanetsky <iliaa@php.net>2003-08-27 23:53:15 +0000
commit32b5df0bc7aaca7ec121cbebc623cecd53ed64f0 (patch)
tree5af7ec6840559cc72fa27bfd19051dbe17f0d427
parent2db5c7de85e842092ec8b47608444d8d59445528 (diff)
downloadphp-git-32b5df0bc7aaca7ec121cbebc623cecd53ed64f0.tar.gz
Prevent abrupt script execution when sendmail_path contains invalid
executable. Add more detail to the warnings regarding execution of sendmail binary.
-rw-r--r--ext/standard/mail.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/ext/standard/mail.c b/ext/standard/mail.c
index b0412904e0..9bdc8fce32 100644
--- a/ext/standard/mail.c
+++ b/ext/standard/mail.c
@@ -198,6 +198,13 @@ PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char
#ifdef PHP_WIN32
sendmail = popen(sendmail_cmd, "wb");
#else
+ /* make sure that sendmail_path contains a valid executable, failure to do
+ * would make PHP abruptly exit without a useful error message. */
+ if (access(sendmail_path, X_OK)) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Permission denied: unable to execute shell to run mail delivery binary '%s'", sendmail_path);
+ return 0;
+ }
+
/* Since popen() doesn't indicate if the internal fork() doesn't work
* (e.g. the shell can't be executed) we explicitely set it to 0 to be
* sure we don't catch any older errno value. */
@@ -210,7 +217,7 @@ PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char
if (sendmail) {
#ifndef PHP_WIN32
if (EACCES == errno) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Permission denied: unable to execute shell to run mail delivery binary");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Permission denied: unable to execute shell to run mail delivery binary '%s'", sendmail_path);
pclose(sendmail);
return 0;
}
@@ -239,7 +246,7 @@ PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char
return 1;
}
} else {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not execute mail delivery program");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not execute mail delivery program '%s'", sendmail_path);
return 0;
}