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
1 change: 1 addition & 0 deletions Zend/zend_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,7 @@ default: ZEND_UNREACHABLE();
_(ZEND_STR_CONST_EXPR_PLACEHOLDER, "[constant expression]") \
_(ZEND_STR_DEPRECATED_CAPITALIZED, "Deprecated") \
_(ZEND_STR_SINCE, "since") \
_(ZEND_STR_NODISCARD, "NoDiscard") \
_(ZEND_STR_GET, "get") \
_(ZEND_STR_SET, "set") \
_(ZEND_STR_8_DOT_0, "8.0") \
Expand Down
1 change: 1 addition & 0 deletions build/gen_stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -2976,6 +2976,7 @@ class StringBuilder {
// NEW in 8.6
private const PHP_86_KNOWN = [
"arguments" => "ZEND_STR_ARGUMENTS",
"NoDiscard" => "ZEND_STR_NODISCARD",
];

/**
Expand Down
36 changes: 9 additions & 27 deletions ext/date/php_date_arginfo.h

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

4 changes: 2 additions & 2 deletions ext/soap/php_encoding.c
Original file line number Diff line number Diff line change
Expand Up @@ -2052,7 +2052,7 @@ static int calc_dimension_12(const char* str)

static void soap_array_position_add_digit(int *position, int digit)
{
if (*position > (INT_MAX - digit) / 10) {
if (UNEXPECTED(*position > (INT_MAX - digit) / 10)) {
soap_error0(E_ERROR, "Encoding: array index out of range");
}

Expand Down Expand Up @@ -2697,7 +2697,7 @@ static zval *to_zval_array(zval *ret, encodeTypePtr type, xmlNodePtr data)
i = dimension;
while (i > 0) {
i--;
if (pos[i] == INT_MAX) {
if (UNEXPECTED(pos[i] == INT_MAX)) {
efree(dims);
efree(pos);
zval_ptr_dtor(ret);
Expand Down
10 changes: 5 additions & 5 deletions ext/soap/php_http.c
Original file line number Diff line number Diff line change
Expand Up @@ -1488,7 +1488,7 @@ static zend_string* get_http_body(php_stream *stream, bool close, zend_string *h
if (buf_size > 0) {
size_t len_size = 0;

if (http_buf_size + buf_size + 1 < 0) {
if (UNEXPECTED(http_buf_size + buf_size + 1 < 0)) {
if (http_buf) {
zend_string_release_ex(http_buf, 0);
}
Expand All @@ -1503,7 +1503,7 @@ static zend_string* get_http_body(php_stream *stream, bool close, zend_string *h

while (len_size < buf_size) {
ssize_t len_read = php_stream_read(stream, http_buf->val + http_buf_size, buf_size - len_size);
if (len_read <= 0) {
if (UNEXPECTED(len_read <= 0)) {
/* Error or EOF */
done = true;
break;
Expand All @@ -1517,7 +1517,7 @@ static zend_string* get_http_body(php_stream *stream, bool close, zend_string *h
if (ch == '\r') {
ch = php_stream_getc(stream);
}
if (ch != '\n') {
if (UNEXPECTED(ch != '\n')) {
/* Something wrong in chunked encoding */
if (http_buf) {
zend_string_release_ex(http_buf, 0);
Expand Down Expand Up @@ -1555,13 +1555,13 @@ static zend_string* get_http_body(php_stream *stream, bool close, zend_string *h
}

} else if (header_length) {
if (header_length < 0 || header_length >= INT_MAX) {
if (UNEXPECTED(header_length < 0 || header_length >= INT_MAX)) {
return NULL;
}
http_buf = zend_string_alloc(header_length, 0);
while (http_buf_size < header_length) {
ssize_t len_read = php_stream_read(stream, http_buf->val + http_buf_size, header_length - http_buf_size);
if (len_read <= 0) {
if (UNEXPECTED(len_read <= 0)) {
break;
}
http_buf_size += len_read;
Expand Down
10 changes: 5 additions & 5 deletions ext/soap/php_packet_soap.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ bool parse_packet_soap(zval *this_ptr, zend_string *buffer, sdlFunctionPtr fn, z
/* Parse XML packet */
response = soap_xmlParseMemory(ZSTR_VAL(buffer), ZSTR_LEN(buffer));

if (!response) {
if (UNEXPECTED(!response)) {
add_soap_fault(this_ptr, "Client", "looks like we got no XML document", NULL, NULL, soap_lang_en);
return false;
}
if (xmlGetIntSubset(response) != NULL) {
if (UNEXPECTED(xmlGetIntSubset(response) != NULL)) {
add_soap_fault(this_ptr, "Client", "DTD are not supported by SOAP", NULL, NULL, soap_lang_en);
xmlFreeDoc(response);
return false;
Expand All @@ -90,7 +90,7 @@ bool parse_packet_soap(zval *this_ptr, zend_string *buffer, sdlFunctionPtr fn, z
}
trav = trav->next;
}
if (env == NULL) {
if (UNEXPECTED(env == NULL)) {
add_soap_fault(this_ptr, "Client", "looks like we got XML without \"Envelope\" element", NULL, NULL, soap_lang_en);
xmlFreeDoc(response);
return false;
Expand Down Expand Up @@ -139,7 +139,7 @@ bool parse_packet_soap(zval *this_ptr, zend_string *buffer, sdlFunctionPtr fn, z
while (trav != NULL && trav->type != XML_ELEMENT_NODE) {
trav = trav->next;
}
if (body == NULL) {
if (UNEXPECTED(body == NULL)) {
add_soap_fault(this_ptr, "Client", "Body must be present in a SOAP envelope", NULL, NULL, soap_lang_en);
xmlFreeDoc(response);
return false;
Expand All @@ -165,7 +165,7 @@ bool parse_packet_soap(zval *this_ptr, zend_string *buffer, sdlFunctionPtr fn, z
}
attr = attr->next;
}
if (trav != NULL && soap_version == SOAP_1_2) {
if (UNEXPECTED(trav != NULL && soap_version == SOAP_1_2)) {
add_soap_fault(this_ptr, "Client", "A SOAP 1.2 envelope can contain only Header and Body", NULL, NULL, soap_lang_en);
xmlFreeDoc(response);
return false;
Expand Down
4 changes: 2 additions & 2 deletions ext/soap/php_schema.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ static int schema_parse_int(const xmlChar *value, const char *name, bool allow_n
if (type != IS_LONG) {
errno = 0;
lval = ZEND_STRTOL(str, NULL, 10);
if (oflow_info || (errno == ERANGE && lval != 0)) {
if (UNEXPECTED(oflow_info || (errno == ERANGE && lval != 0))) {
soap_error1(E_ERROR, "Parsing Schema: %s value is out of range", name);
}
}

if (ZEND_LONG_EXCEEDS_INT(lval) || (!allow_negative && lval < 0)) {
if (UNEXPECTED(ZEND_LONG_EXCEEDS_INT(lval) || (!allow_negative && lval < 0))) {
soap_error1(E_ERROR, "Parsing Schema: %s value is out of range", name);
}

Expand Down
10 changes: 5 additions & 5 deletions ext/soap/php_sdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1524,22 +1524,22 @@ static sdlPtr get_sdl_from_cache(const char *fn, const char *uri, size_t uri_len
char *in, *buf;

f = open(fn, O_RDONLY|O_BINARY);
if (f < 0) {
if (UNEXPECTED(f < 0)) {
return NULL;
}
if (fstat(f, &st) != 0) {
if (UNEXPECTED(fstat(f, &st) != 0)) {
close(f);
return NULL;
}
buf = in = emalloc(st.st_size);
if (read(f, in, st.st_size) != st.st_size) {
if (UNEXPECTED(read(f, in, st.st_size) != st.st_size)) {
close(f);
efree(in);
return NULL;
}
close(f);

if (strncmp(in,"wsdl",4) != 0 || in[4] != WSDL_CACHE_VERSION || in[5] != '\0') {
if (UNEXPECTED(strncmp(in,"wsdl",4) != 0 || in[4] != WSDL_CACHE_VERSION || in[5] != '\0')) {
unlink(fn);
efree(buf);
return NULL;
Expand Down Expand Up @@ -2096,7 +2096,7 @@ static void add_sdl_to_cache(const char *fn, const char *uri, time_t t, sdlPtr s
zend_string *temp_file_path;
f = php_open_temporary_fd_ex(SOAP_GLOBAL(cache_dir), "tmp.wsdl.", &temp_file_path, PHP_TMP_FILE_SILENT);

if (f < 0) {return;}
if (UNEXPECTED(f < 0)) {return;}

zend_hash_init(&tmp_types, 0, NULL, NULL, 0);
zend_hash_init(&tmp_encoders, 0, NULL, NULL, 0);
Expand Down
6 changes: 3 additions & 3 deletions ext/soap/soap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,7 @@ PHP_METHOD(SoapServer, __construct)
goto cleanup;
}
// TODO: this still accepts mixed keys arrays and not all numerically indexed arrays are packed
if (HT_IS_PACKED(Z_ARRVAL_P(class_map_zv))) {
if (UNEXPECTED(HT_IS_PACKED(Z_ARRVAL_P(class_map_zv)))) {
zend_argument_value_error(2, "\"classmap\" option must be an associative array");
goto cleanup;
}
Expand Down Expand Up @@ -2224,7 +2224,7 @@ PHP_METHOD(SoapClient, __construct)
xmlCharEncodingHandlerPtr encoding;

encoding = xmlFindCharEncodingHandler(Z_STRVAL_P(tmp));
if (encoding == NULL) {
if (UNEXPECTED(encoding == NULL)) {
php_error_docref(NULL, E_ERROR, "Invalid 'encoding' option - '%s'", Z_STRVAL_P(tmp));
} else {
xmlCharEncCloseFunc(encoding);
Expand All @@ -2233,7 +2233,7 @@ PHP_METHOD(SoapClient, __construct)
}
if ((tmp = zend_hash_str_find(ht, "classmap", sizeof("classmap")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_ARRAY) {
if (HT_IS_PACKED(Z_ARRVAL_P(tmp))) {
if (UNEXPECTED(HT_IS_PACKED(Z_ARRVAL_P(tmp)))) {
php_error_docref(NULL, E_ERROR, "'classmap' option must be an associative array");
}
ZVAL_COPY(Z_CLIENT_CLASSMAP_P(this_ptr), tmp);
Expand Down
2 changes: 2 additions & 0 deletions main/poll/poll_backend_epoll.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ static int epoll_backend_wait(
events[i].revents = epoll_events_from_native(backend_data->events[i].events);
events[i].data = backend_data->events[i].data.ptr;
}
} else if (nfds < 0) {
php_poll_set_current_errno_error(ctx);
}

return nfds;
Expand Down
5 changes: 5 additions & 0 deletions main/poll/poll_backend_kqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,11 @@ static int kqueue_backend_wait(
int nfds = kevent(
backend_data->kqueue_fd, NULL, 0, backend_data->events, required_capacity, timeout);

if (nfds < 0) {
php_poll_set_current_errno_error(ctx);
return -1;
}

if (nfds > 0) {
if (ctx->raw_events) {
/* Raw events mode - direct 1:1 mapping, no grouping */
Expand Down
7 changes: 5 additions & 2 deletions main/poll/poll_backend_poll.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,11 @@ static int poll_backend_wait(
int timeout_ms = php_poll_timespec_to_ms(timeout);
int nfds = poll(backend_data->temp_fds, fd_count, timeout_ms);

if (nfds <= 0) {
return nfds; /* Return 0 for timeout, -1 for error */
if (nfds < 0) {
php_poll_set_current_errno_error(ctx);
return -1;
} else if (nfds == 0) {
return 0; /* timeout */
}

/* Process results - iterate through struct pollfd array directly */
Expand Down