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 NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ PHP NEWS
header is correct). (nielsdos)
. Fix namespace handling of WSDL and XML schema in SOAP,
fixing at least GH-16320 and bug #68576. (nielsdos)
. Fixed bug #70951 (Segmentation fault on invalid WSDL cache). (nielsdos)

- Sockets:
. Added IPPROTO_ICMP/IPPROTO_ICMPV6 to create raw socket for ICMP usage.
Expand Down
26 changes: 26 additions & 0 deletions Zend/tests/ast/ast_serialize_floats.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
--TEST--
Serialization of floats are correct
--INI--
zend.assertions=1
--FILE--
<?php
try {
assert(!is_float(0.0));
} catch (AssertionError $e) {
echo 'assert(): ', $e->getMessage(), ' failed', PHP_EOL;
}
try {
assert(!is_float(1.1));
} catch (AssertionError $e) {
echo 'assert(): ', $e->getMessage(), ' failed', PHP_EOL;
}
try {
assert(!is_float(1234.5678));
} catch (AssertionError $e) {
echo 'assert(): ', $e->getMessage(), ' failed', PHP_EOL;
}
?>
--EXPECT--
assert(): assert(!is_float(0.0)) failed
assert(): assert(!is_float(1.1)) failed
assert(): assert(!is_float(1234.5678)) failed
16 changes: 8 additions & 8 deletions Zend/zend_ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -1820,7 +1820,7 @@ static ZEND_COLD void zend_ast_export_zval(smart_str *str, zval *zv, int priorit
break;
case IS_DOUBLE:
smart_str_append_double(
str, Z_DVAL_P(zv), (int) EG(precision), /* zero_fraction */ false);
str, Z_DVAL_P(zv), (int) EG(precision), /* zero_fraction */ true);
break;
case IS_STRING:
smart_str_appendc(str, '\'');
Expand Down Expand Up @@ -1871,7 +1871,7 @@ static ZEND_COLD void zend_ast_export_class_no_header(smart_str *str, zend_ast_d
smart_str_appends(str, " {\n");
zend_ast_export_stmt(str, decl->child[2], indent + 1);
zend_ast_export_indent(str, indent);
smart_str_appends(str, "}");
smart_str_appendc(str, '}');
}

static ZEND_COLD void zend_ast_export_attribute_group(smart_str *str, zend_ast *ast, int indent) {
Expand Down Expand Up @@ -1899,7 +1899,7 @@ static ZEND_COLD void zend_ast_export_attributes(smart_str *str, zend_ast *ast,
for (i = 0; i < list->children; i++) {
smart_str_appends(str, "#[");
zend_ast_export_attribute_group(str, list->child[i], indent);
smart_str_appends(str, "]");
smart_str_appendc(str, ']');

if (newlines) {
smart_str_appendc(str, '\n');
Expand Down Expand Up @@ -2060,7 +2060,7 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio
case ZEND_AST_OP_ARRAY:
smart_str_appends(str, "Closure(");
smart_str_append(str, zend_ast_get_op_array(ast)->op_array->function_name);
smart_str_appends(str, ")");
smart_str_appendc(str, ')');
break;
case ZEND_AST_CONSTANT_CLASS:
smart_str_appendl(str, "__CLASS__", sizeof("__CLASS__")-1);
Expand Down Expand Up @@ -2427,9 +2427,9 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio
case ZEND_AST_CALL: {
zend_ast *left = ast->child[0];
if (left->kind == ZEND_AST_ARROW_FUNC || left->kind == ZEND_AST_CLOSURE) {
smart_str_appends(str, "(");
smart_str_appendc(str, '(');
zend_ast_export_ns_name(str, left, 0, indent);
smart_str_appends(str, ")");
smart_str_appendc(str, ')');
} else {
zend_ast_export_ns_name(str, left, 0, indent);
}
Expand Down Expand Up @@ -2679,9 +2679,9 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio
smart_str_appends(str, " {\n");
zend_ast_export_ex(str, ast->child[1], 0, indent + 1);
zend_ast_export_indent(str, indent);
smart_str_appends(str, "}");
smart_str_appendc(str, '}');
} else {
smart_str_appends(str, ";");
smart_str_appendc(str, ';');
}
break;
case ZEND_AST_TRAIT_PRECEDENCE:
Expand Down
14 changes: 9 additions & 5 deletions ext/pgsql/pgsql.c
Original file line number Diff line number Diff line change
Expand Up @@ -3879,7 +3879,12 @@ static void php_pgsql_do_async(INTERNAL_FUNCTION_PARAMETERS, int entry_type)
switch(entry_type) {
case PHP_PG_ASYNC_IS_BUSY:
PQconsumeInput(pgsql);
RETVAL_LONG(PQisBusy(pgsql));
/* PQisBusy
* Returns 1 if a command is busy, that is, PQgetResult would block waiting for input.
* A 0 return indicates that PQgetResult can be called with assurance of not blocking.
* https://www.postgresql.org/docs/current/libpq-async.html#LIBPQ-PQISBUSY
*/
RETVAL_BOOL(PQisBusy(pgsql));
break;
case PHP_PG_ASYNC_REQUEST_CANCEL: {
PGcancel *c;
Expand All @@ -3893,7 +3898,8 @@ static void php_pgsql_do_async(INTERNAL_FUNCTION_PARAMETERS, int entry_type)
* errbuf must be a char array of size errbufsize (the recommended size is 256 bytes).
* https://www.postgresql.org/docs/current/libpq-cancel.html#LIBPQ-PQCANCEL
*/
RETVAL_LONG((rc = PQcancel(c, err, sizeof(err))));
rc = PQcancel(c, err, sizeof(err));
RETVAL_BOOL(rc);
if (rc == 0) {
zend_error(E_WARNING, "cannot cancel the query: %s", err);
}
Expand All @@ -3908,7 +3914,6 @@ static void php_pgsql_do_async(INTERNAL_FUNCTION_PARAMETERS, int entry_type)
if (PQsetnonblocking(pgsql, 0)) {
php_error_docref(NULL, E_NOTICE, "Cannot set connection to blocking mode");
}
convert_to_boolean(return_value);
}
/* }}} */

Expand Down Expand Up @@ -4929,8 +4934,7 @@ PHP_PGSQL_API zend_result php_pgsql_convert(PGconn *pg_link, const zend_string *
break; /* break out for() */
}

convert_to_boolean(is_enum);
if (Z_TYPE_P(is_enum) == IS_TRUE) {
if (zval_is_true(is_enum)) {
/* enums need to be treated like strings */
data_type = PG_TEXT;
} else {
Expand Down
4 changes: 2 additions & 2 deletions ext/soap/php_encoding.c
Original file line number Diff line number Diff line change
Expand Up @@ -3456,7 +3456,7 @@ xmlNsPtr encode_add_ns(xmlNodePtr node, const char* ns)
if (xmlns == NULL) {
xmlChar* prefix;

if ((prefix = zend_hash_str_find_ptr(&SOAP_GLOBAL(defEncNs), (char*)ns, strlen(ns))) != NULL) {
if ((prefix = zend_hash_str_find_ptr(&php_soap_defEncNs, (char*)ns, strlen(ns))) != NULL) {
xmlns = xmlNewNs(node->doc->children, BAD_CAST(ns), prefix);
} else {
smart_str prefix = {0};
Expand Down Expand Up @@ -3531,7 +3531,7 @@ encodePtr get_conversion(int encode)
{
encodePtr enc;

if ((enc = zend_hash_index_find_ptr(&SOAP_GLOBAL(defEncIndex), encode)) == NULL) {
if ((enc = zend_hash_index_find_ptr(&php_soap_defEncIndex, encode)) == NULL) {
soap_error0(E_ERROR, "Encoding: Cannot find encoding");
return NULL;
} else {
Expand Down
12 changes: 11 additions & 1 deletion ext/soap/php_sdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
# define O_BINARY 0
#endif

#ifdef WORDS_BIGENDIAN
# define SOAP_BIG_ENDIAN 1
#else
# define SOAP_BIG_ENDIAN 0
#endif

static void delete_fault(zval *zv);
static void delete_fault_persistent(zval *zv);
static void delete_binding(zval *zv);
Expand Down Expand Up @@ -177,7 +183,7 @@ encodePtr get_encoder_ex(sdlPtr sdl, const char *nscat, size_t len)
{
encodePtr enc;

if ((enc = zend_hash_str_find_ptr(&SOAP_GLOBAL(defEnc), nscat, len)) != NULL) {
if ((enc = zend_hash_str_find_ptr(&php_soap_defEnc, nscat, len)) != NULL) {
return enc;
} else if (sdl && sdl->encoders && (enc = zend_hash_str_find_ptr(sdl->encoders, nscat, len)) != NULL) {
return enc;
Expand Down Expand Up @@ -3188,9 +3194,13 @@ sdlPtr get_sdl(zval *this_ptr, char *uri, zend_long cache_wsdl)
char *user = php_get_current_user();
size_t user_len = user ? strlen(user) + 1 : 0;

/* System architecture identification (see bug #70951) */
static const char ids[] = {SIZEOF_ZEND_LONG, SOAP_BIG_ENDIAN};

md5str[0] = '\0';
PHP_MD5Init(&md5_context);
PHP_MD5Update(&md5_context, (unsigned char*)uri, uri_len);
PHP_MD5Update(&md5_context, ids, sizeof(ids));
PHP_MD5Final(digest, &md5_context);
make_digest(md5str, digest);
key = emalloc(len+sizeof("/wsdl-")-1+user_len+2+sizeof(md5str));
Expand Down
5 changes: 2 additions & 3 deletions ext/soap/php_soap.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,6 @@ struct _soapService {


ZEND_BEGIN_MODULE_GLOBALS(soap)
HashTable defEncNs; /* mapping of default namespaces to prefixes */
HashTable defEnc;
HashTable defEncIndex;
HashTable *typemap;
int cur_uniq_ns;
int soap_version;
Expand Down Expand Up @@ -195,6 +192,8 @@ extern zend_class_entry* soap_var_class_entry;
extern zend_class_entry* soap_url_class_entry;
extern zend_class_entry* soap_sdl_class_entry;

extern HashTable php_soap_defEncNs, php_soap_defEnc, php_soap_defEncIndex;

void add_soap_fault(zval *obj, char *fault_code, char *fault_string, char *fault_actor, zval *fault_detail);

#define soap_error0(severity, format) \
Expand Down
39 changes: 19 additions & 20 deletions ext/soap/soap.c
Original file line number Diff line number Diff line change
Expand Up @@ -390,16 +390,18 @@ STD_PHP_INI_ENTRY("soap.wsdl_cache_limit", "5", PHP_INI_ALL, OnUpdateLong,
cache_limit, zend_soap_globals, soap_globals)
PHP_INI_END()

static HashTable defEnc, defEncIndex, defEncNs;
/* Real globals shared for the entire processes across threads, only written during init. */
HashTable php_soap_defEncNs; /* mapping of default namespaces to prefixes */
HashTable php_soap_defEnc, php_soap_defEncIndex;

static void php_soap_prepare_globals(void)
{
int i;
encode* enc;

zend_hash_init(&defEnc, 0, NULL, NULL, 1);
zend_hash_init(&defEncIndex, 0, NULL, NULL, 1);
zend_hash_init(&defEncNs, 0, NULL, NULL, 1);
zend_hash_init(&php_soap_defEnc, 0, NULL, NULL, 1);
zend_hash_init(&php_soap_defEncIndex, 0, NULL, NULL, 1);
zend_hash_init(&php_soap_defEncNs, 0, NULL, NULL, 1);

i = 0;
do {
Expand All @@ -412,35 +414,32 @@ static void php_soap_prepare_globals(void)
size_t clark_notation_len = spprintf(&clark_notation, 0, "{%s}%s", enc->details.ns, enc->details.type_str);
enc->details.clark_notation = zend_string_init(clark_notation, clark_notation_len, true);
size_t ns_type_len = spprintf(&ns_type, 0, "%s:%s", enc->details.ns, enc->details.type_str);
zend_hash_str_add_ptr(&defEnc, ns_type, ns_type_len, (void*)enc);
zend_hash_str_add_ptr(&php_soap_defEnc, ns_type, ns_type_len, (void*)enc);
efree(clark_notation);
efree(ns_type);
} else {
zend_hash_str_add_ptr(&defEnc, defaultEncoding[i].details.type_str, strlen(defaultEncoding[i].details.type_str), (void*)enc);
zend_hash_str_add_ptr(&php_soap_defEnc, defaultEncoding[i].details.type_str, strlen(defaultEncoding[i].details.type_str), (void*)enc);
}
}
/* Index everything by number */
zend_hash_index_add_ptr(&defEncIndex, defaultEncoding[i].details.type, (void*)enc);
zend_hash_index_add_ptr(&php_soap_defEncIndex, defaultEncoding[i].details.type, (void*)enc);
i++;
} while (defaultEncoding[i].details.type != END_KNOWN_TYPES);

/* hash by namespace */
zend_hash_str_add_ptr(&defEncNs, XSD_1999_NAMESPACE, sizeof(XSD_1999_NAMESPACE)-1, XSD_NS_PREFIX);
zend_hash_str_add_ptr(&defEncNs, XSD_NAMESPACE, sizeof(XSD_NAMESPACE)-1, XSD_NS_PREFIX);
zend_hash_str_add_ptr(&defEncNs, XSI_NAMESPACE, sizeof(XSI_NAMESPACE)-1, XSI_NS_PREFIX);
zend_hash_str_add_ptr(&defEncNs, XML_NAMESPACE, sizeof(XML_NAMESPACE)-1, XML_NS_PREFIX);
zend_hash_str_add_ptr(&defEncNs, SOAP_1_1_ENC_NAMESPACE, sizeof(SOAP_1_1_ENC_NAMESPACE)-1, SOAP_1_1_ENC_NS_PREFIX);
zend_hash_str_add_ptr(&defEncNs, SOAP_1_2_ENC_NAMESPACE, sizeof(SOAP_1_2_ENC_NAMESPACE)-1, SOAP_1_2_ENC_NS_PREFIX);
zend_hash_str_add_ptr(&php_soap_defEncNs, XSD_1999_NAMESPACE, sizeof(XSD_1999_NAMESPACE)-1, XSD_NS_PREFIX);
zend_hash_str_add_ptr(&php_soap_defEncNs, XSD_NAMESPACE, sizeof(XSD_NAMESPACE)-1, XSD_NS_PREFIX);
zend_hash_str_add_ptr(&php_soap_defEncNs, XSI_NAMESPACE, sizeof(XSI_NAMESPACE)-1, XSI_NS_PREFIX);
zend_hash_str_add_ptr(&php_soap_defEncNs, XML_NAMESPACE, sizeof(XML_NAMESPACE)-1, XML_NS_PREFIX);
zend_hash_str_add_ptr(&php_soap_defEncNs, SOAP_1_1_ENC_NAMESPACE, sizeof(SOAP_1_1_ENC_NAMESPACE)-1, SOAP_1_1_ENC_NS_PREFIX);
zend_hash_str_add_ptr(&php_soap_defEncNs, SOAP_1_2_ENC_NAMESPACE, sizeof(SOAP_1_2_ENC_NAMESPACE)-1, SOAP_1_2_ENC_NS_PREFIX);
}

static void php_soap_init_globals(zend_soap_globals *soap_globals)
{
#if defined(COMPILE_DL_SOAP) && defined(ZTS)
ZEND_TSRMLS_CACHE_UPDATE();
#endif
soap_globals->defEnc = defEnc;
soap_globals->defEncIndex = defEncIndex;
soap_globals->defEncNs = defEncNs;
soap_globals->typemap = NULL;
soap_globals->use_soap_error_handler = 0;
soap_globals->error_code = NULL;
Expand All @@ -461,9 +460,9 @@ PHP_MSHUTDOWN_FUNCTION(soap)
i++;
} while (defaultEncoding[i].details.type != END_KNOWN_TYPES);
zend_error_cb = old_error_handler;
zend_hash_destroy(&SOAP_GLOBAL(defEnc));
zend_hash_destroy(&SOAP_GLOBAL(defEncIndex));
zend_hash_destroy(&SOAP_GLOBAL(defEncNs));
zend_hash_destroy(&php_soap_defEnc);
zend_hash_destroy(&php_soap_defEncIndex);
zend_hash_destroy(&php_soap_defEncNs);
if (SOAP_GLOBAL(mem_cache)) {
zend_hash_destroy(SOAP_GLOBAL(mem_cache));
free(SOAP_GLOBAL(mem_cache));
Expand Down Expand Up @@ -765,7 +764,7 @@ PHP_METHOD(SoapVar, __construct)
if (type_is_null) {
ZVAL_LONG(Z_VAR_ENC_TYPE_P(this_ptr), UNKNOWN_TYPE);
} else {
if (zend_hash_index_exists(&SOAP_GLOBAL(defEncIndex), type)) {
if (zend_hash_index_exists(&php_soap_defEncIndex, type)) {
ZVAL_LONG(Z_VAR_ENC_TYPE_P(this_ptr), type);
} else {
zend_argument_value_error(2, "is not a valid encoding");
Expand Down