Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ PHP NEWS
. Added array_first() and array_last(). (nielsdos)
. Fixed bug GH-18823 (setlocale's 2nd and 3rd argument ignores strict_types).
(nielsdos)
. Fixed exit code handling of sendmail cmd and added warnings.
(Jesse Hathaway)

- Streams:
. Fixed bug GH-16889 (stream_select() timeout useless for pipes on Windows).
Expand Down
6 changes: 6 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,12 @@ PHP 8.5 UPGRADE NOTES
Sqlite3Stmt::EXPLAIN_MODE_EXPLAIN and
Sqlite3Stmt::EXPLAIN_MODE_EXPLAIN_QUERY_PLAN.

- Standard:
. mail() now returns the actual sendmail error and detects if the sendmail
process was terminated unexpectedly. In such cases, a warning is emitted
and the function returns false. Previously, these errors were silently
ignored. This change affects only the sendmail transport.

- XSL:
. The $namespace argument of XSLTProcessor::getParameter(),
XSLTProcessor::setParameter() and XSLTProcessor::removeParameter()
Expand Down
2 changes: 2 additions & 0 deletions UPGRADING.INTERNALS
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ PHP 8.5 INTERNALS UPGRADE NOTES
. Added the zend_update_exception_properties() function for instantiating
Exception child classes. It updates the $message, $code, and $previous
properties.
. ZEND_IS_XDIGIT() macro was removed because it was unused and its name
did not match its actual behavior.

========================
2. Build system changes
Expand Down
1 change: 0 additions & 1 deletion Zend/zend_operators.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ static zend_always_inline zend_long zend_dval_to_lval_safe(double d)
}

#define ZEND_IS_DIGIT(c) ((c) >= '0' && (c) <= '9')
#define ZEND_IS_XDIGIT(c) (((c) >= 'A' && (c) <= 'F') || ((c) >= 'a' && (c) <= 'f'))

static zend_always_inline uint8_t is_numeric_string_ex(const char *str, size_t length, zend_long *lval,
double *dval, bool allow_errors, int *oflow_info, bool *trailing_data)
Expand Down
36 changes: 31 additions & 5 deletions ext/standard/mail.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
#include "ext/date/php_date.h"
#include "zend_smart_str.h"

#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif

#ifdef HAVE_SYSEXITS_H
# include <sysexits.h>
#endif
Expand Down Expand Up @@ -562,6 +566,7 @@ PHPAPI bool php_mail(const char *to, const char *subject, const char *message, c
}

if (sendmail) {
int ret;
#ifndef PHP_WIN32
if (EACCES == errno) {
php_error_docref(NULL, E_WARNING, "Permission denied: unable to execute shell to run mail delivery binary '%s'", sendmail_path);
Expand All @@ -582,26 +587,47 @@ PHPAPI bool php_mail(const char *to, const char *subject, const char *message, c
fprintf(sendmail, "%s%s", hdr, line_sep);
}
fprintf(sendmail, "%s%s%s", line_sep, message, line_sep);
int ret = pclose(sendmail);
#ifdef PHP_WIN32
ret = pclose(sendmail);

#if PHP_SIGCHILD
if (sig_handler) {
signal(SIGCHLD, sig_handler);
}
#endif

#ifdef PHP_WIN32
if (ret == -1)
#else
int wstatus = pclose(sendmail);
#if PHP_SIGCHILD
if (sig_handler) {
signal(SIGCHLD, sig_handler);
}
#endif
/* Determine the wait(2) exit status */
if (wstatus == -1) {
php_error_docref(NULL, E_WARNING, "Sendmail pclose failed %d (%s)", errno, strerror(errno));
MAIL_RET(false);
} else if (WIFSIGNALED(wstatus)) {
php_error_docref(NULL, E_WARNING, "Sendmail killed by signal %d (%s)", WTERMSIG(wstatus), strsignal(WTERMSIG(wstatus)));
MAIL_RET(false);
} else {
if (WIFEXITED(wstatus)) {
ret = WEXITSTATUS(wstatus);
} else {
php_error_docref(NULL, E_WARNING, "Sendmail did not exit");
MAIL_RET(false);
}
}
#endif

#if defined(EX_TEMPFAIL)
if ((ret != EX_OK)&&(ret != EX_TEMPFAIL))
#elif defined(EX_OK)
if (ret != EX_OK)
#else
if (ret != 0)
#endif
#endif
{
php_error_docref(NULL, E_WARNING, "Sendmail exited with non-zero exit code %d", ret);
MAIL_RET(false);
} else {
MAIL_RET(true);
Expand Down
3 changes: 2 additions & 1 deletion ext/standard/tests/mail/gh10990.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ $from = 'test@example.com';
$headers = ['From' => &$from];
var_dump(mail('test@example.com', 'Test', 'Test', $headers));
?>
--EXPECT--
--EXPECTF--
Warning: mail(): Sendmail exited with non-zero exit code 127 in %sgh10990.php on line %d
bool(false)
4 changes: 3 additions & 1 deletion ext/standard/tests/mail/mail_basic5.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ $message = 'A Message';
echo "-- failure --\n";
var_dump( mail($to, $subject, $message) );
?>
--EXPECT--
--EXPECTF--
*** Testing mail() : basic functionality ***
-- failure --

Warning: mail(): Sendmail exited with non-zero exit code 1 in %smail_basic5.php on line %d
bool(false)
4 changes: 3 additions & 1 deletion ext/standard/tests/mail/mail_variation1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ $subject = 'Test Subject';
$message = 'A Message';
var_dump( mail($to, $subject, $message) );
?>
--EXPECT--
--EXPECTF--
*** Testing mail() : variation ***

Warning: mail(): Sendmail exited with non-zero exit code 127 in %smail_variation1.php on line %d
bool(false)
22 changes: 22 additions & 0 deletions ext/standard/tests/mail/mail_variation3.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--TEST--
Test mail() function : variation sendmail temp fail
--INI--
sendmail_path=exit 75
--SKIPIF--
<?php
if (substr(PHP_OS, 0, 3) == "WIN")
die("skip Won't run on Windows");
?>
--FILE--
<?php
echo "*** Testing mail() : variation ***\n";

// Initialise all required variables
$to = 'user@example.com';
$subject = 'Test Subject';
$message = 'A Message';
var_dump(mail($to, $subject, $message));
?>
--EXPECT--
*** Testing mail() : variation ***
bool(true)
24 changes: 24 additions & 0 deletions ext/standard/tests/mail/mail_variation4.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
--TEST--
Test mail() function : variation sigterm
--INI--
sendmail_path="kill \$\$"
--SKIPIF--
<?php
if (substr(PHP_OS, 0, 3) == "WIN")
die("skip Won't run on Windows");
?>
--FILE--
<?php
echo "*** Testing mail() : variation ***\n";

// Initialise all required variables
$to = 'user@example.com';
$subject = 'Test Subject';
$message = 'A Message';
var_dump(mail($to, $subject, $message));
?>
--EXPECTF--
*** Testing mail() : variation ***

Warning: mail(): Sendmail killed by signal %d (%s) in %smail_variation4.php on line %d
bool(false)
24 changes: 24 additions & 0 deletions ext/standard/tests/mail/mail_variation5.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
--TEST--
Test mail() function : variation non-zero exit
--INI--
sendmail_path="exit 123"
--SKIPIF--
<?php
if (substr(PHP_OS, 0, 3) == "WIN")
die("skip Won't run on Windows");
?>
--FILE--
<?php
echo "*** Testing mail() : variation ***\n";

// Initialise all required variables
$to = 'user@example.com';
$subject = 'Test Subject';
$message = 'A Message';
var_dump(mail($to, $subject, $message));
?>
--EXPECTF--
*** Testing mail() : variation ***

Warning: mail(): Sendmail exited with non-zero exit code 123 in %smail_variation5.php on line %d
bool(false)
11 changes: 6 additions & 5 deletions main/debug_gdb_scripts.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions scripts/gdb/php_gdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ def children(self):
for field in self.val.type.fields():
if field.name == 'val':
yield ('val', format_zstr(self.val))
elif field.name == 'h':
yield (field.name, "0x%x" % self.val[field.name])
else:
yield (field.name, format_nested(self.val[field.name]))

Expand Down Expand Up @@ -81,12 +83,11 @@ def to_string(self):
def children(self):
for field in self.val.type.fields():
if field.name is None:
name = '<anonymous>'
val = self.val[field]
yield ('<anonymous>', format_nested(self.val[field]))
elif field.name == 'nTableMask':
yield (field.name, "0x%x" % self.val[field.name])
else:
name = field.name
val = self.val[field.name]
yield (name, format_nested(val))
yield (field.name, format_nested(self.val[field.name]))

pp_set.add_printer('zend_array', '^_zend_array$', ZendArrayPrettyPrinter)

Expand Down