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
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
Loading