1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Mark resource-like objects as non-comparable

As these hold on to some internal resource, there can't be two
"equal" objects with different identity. Make sure the lack of
public properties doesn't result in these being treated as always
equal.
This commit is contained in:
Nikita Popov
2021-02-16 14:20:45 +01:00
parent cb9785add1
commit b63ea1047a
13 changed files with 17 additions and 0 deletions

View File

@@ -1200,6 +1200,7 @@ PHP_MINIT_FUNCTION(curl)
curl_object_handlers.get_constructor = curl_get_constructor;
curl_object_handlers.clone_obj = curl_clone_obj;
curl_object_handlers.cast_object = curl_cast_object;
curl_object_handlers.compare = zend_objects_not_comparable;
curl_multi_register_class(class_CurlMultiHandle_methods);
curl_share_register_class(class_CurlShareHandle_methods);

View File

@@ -603,4 +603,5 @@ void curl_multi_register_class(const zend_function_entry *method_entries) {
curl_multi_handlers.get_constructor = curl_multi_get_constructor;
curl_multi_handlers.clone_obj = NULL;
curl_multi_handlers.cast_object = curl_cast_object;
curl_multi_handlers.compare = zend_objects_not_comparable;
}

View File

@@ -176,4 +176,5 @@ void curl_share_register_class(const zend_function_entry *method_entries) {
curl_share_handlers.free_obj = curl_share_free_obj;
curl_share_handlers.get_constructor = curl_share_get_constructor;
curl_share_handlers.clone_obj = NULL;
curl_share_handlers.compare = zend_objects_not_comparable;
}

View File

@@ -199,6 +199,7 @@ PHP_MINIT_FUNCTION(enchant)
enchant_broker_handlers.offset = XtOffsetOf(enchant_broker, std);
enchant_broker_handlers.free_obj = php_enchant_broker_free;
enchant_broker_handlers.clone_obj = NULL;
enchant_broker_handlers.compare = zend_objects_not_comparable;
INIT_CLASS_ENTRY(dce, "EnchantDictionary", class_EnchantDictionary_methods);
enchant_dict_ce = zend_register_internal_class(&dce);
@@ -211,6 +212,7 @@ PHP_MINIT_FUNCTION(enchant)
enchant_dict_handlers.offset = XtOffsetOf(enchant_dict, std);
enchant_dict_handlers.free_obj = php_enchant_dict_free;
enchant_dict_handlers.clone_obj = NULL;
enchant_dict_handlers.compare = zend_objects_not_comparable;
REGISTER_LONG_CONSTANT("ENCHANT_MYSPELL", PHP_ENCHANT_MYSPELL, CONST_CS | CONST_PERSISTENT | CONST_DEPRECATED);
REGISTER_LONG_CONSTANT("ENCHANT_ISPELL", PHP_ENCHANT_ISPELL, CONST_CS | CONST_PERSISTENT | CONST_DEPRECATED);

View File

@@ -232,6 +232,7 @@ static void php_gd_object_minit_helper()
php_gd_image_object_handlers.clone_obj = NULL;
php_gd_image_object_handlers.free_obj = php_gd_image_object_free;
php_gd_image_object_handlers.get_constructor = php_gd_image_object_get_constructor;
php_gd_image_object_handlers.compare = zend_objects_not_comparable;
php_gd_image_object_handlers.offset = XtOffsetOf(php_gd_image_object, std);
}

View File

@@ -1116,6 +1116,7 @@ PHP_MINIT_FUNCTION(openssl)
php_openssl_certificate_object_handlers.free_obj = php_openssl_certificate_free_obj;
php_openssl_certificate_object_handlers.get_constructor = php_openssl_certificate_get_constructor;
php_openssl_certificate_object_handlers.clone_obj = NULL;
php_openssl_certificate_object_handlers.compare = zend_objects_not_comparable;
zend_class_entry csr_ce;
INIT_CLASS_ENTRY(csr_ce, "OpenSSLCertificateSigningRequest", class_OpenSSLCertificateSigningRequest_methods);
@@ -1130,6 +1131,7 @@ PHP_MINIT_FUNCTION(openssl)
php_openssl_request_object_handlers.free_obj = php_openssl_request_free_obj;
php_openssl_request_object_handlers.get_constructor = php_openssl_request_get_constructor;
php_openssl_request_object_handlers.clone_obj = NULL;
php_openssl_request_object_handlers.compare = zend_objects_not_comparable;
zend_class_entry key_ce;
INIT_CLASS_ENTRY(key_ce, "OpenSSLAsymmetricKey", class_OpenSSLAsymmetricKey_methods);
@@ -1144,6 +1146,7 @@ PHP_MINIT_FUNCTION(openssl)
php_openssl_pkey_object_handlers.free_obj = php_openssl_pkey_free_obj;
php_openssl_pkey_object_handlers.get_constructor = php_openssl_pkey_get_constructor;
php_openssl_pkey_object_handlers.clone_obj = NULL;
php_openssl_pkey_object_handlers.compare = zend_objects_not_comparable;
#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined (LIBRESSL_VERSION_NUMBER)
OPENSSL_config(NULL);

View File

@@ -121,6 +121,7 @@ PHP_MINIT_FUNCTION(shmop)
shmop_object_handlers.free_obj = shmop_free_obj;
shmop_object_handlers.get_constructor = shmop_get_constructor;
shmop_object_handlers.clone_obj = NULL;
shmop_object_handlers.compare = zend_objects_not_comparable;
return SUCCESS;
}

View File

@@ -461,6 +461,7 @@ static PHP_MINIT_FUNCTION(sockets)
address_info_object_handlers.free_obj = address_info_free_obj;
address_info_object_handlers.get_constructor = address_info_get_constructor;
address_info_object_handlers.clone_obj = NULL;
address_info_object_handlers.compare = zend_objects_not_comparable;
REGISTER_LONG_CONSTANT("AF_UNIX", AF_UNIX, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("AF_INET", AF_INET, CONST_CS | CONST_PERSISTENT);

View File

@@ -121,6 +121,7 @@ PHP_MINIT_FUNCTION(sysvmsg)
sysvmsg_queue_object_handlers.free_obj = sysvmsg_queue_free_obj;
sysvmsg_queue_object_handlers.get_constructor = sysvmsg_queue_get_constructor;
sysvmsg_queue_object_handlers.clone_obj = NULL;
sysvmsg_queue_object_handlers.compare = zend_objects_not_comparable;
REGISTER_LONG_CONSTANT("MSG_IPC_NOWAIT", PHP_MSG_IPC_NOWAIT, CONST_PERSISTENT|CONST_CS);
REGISTER_LONG_CONSTANT("MSG_EAGAIN", EAGAIN, CONST_PERSISTENT|CONST_CS);

View File

@@ -164,6 +164,7 @@ PHP_MINIT_FUNCTION(sysvsem)
sysvsem_object_handlers.free_obj = sysvsem_free_obj;
sysvsem_object_handlers.get_constructor = sysvsem_get_constructor;
sysvsem_object_handlers.clone_obj = NULL;
sysvsem_object_handlers.compare = zend_objects_not_comparable;
return SUCCESS;
}

View File

@@ -112,6 +112,7 @@ PHP_MINIT_FUNCTION(sysvshm)
sysvshm_object_handlers.free_obj = sysvshm_free_obj;
sysvshm_object_handlers.get_constructor = sysvshm_get_constructor;
sysvshm_object_handlers.clone_obj = NULL;
sysvshm_object_handlers.compare = zend_objects_not_comparable;
if (cfg_get_long("sysvshm.init_mem", &php_sysvshm.init_mem) == FAILURE) {
php_sysvshm.init_mem=10000;

View File

@@ -267,6 +267,7 @@ PHP_MINIT_FUNCTION(xml)
xml_parser_object_handlers.get_gc = xml_parser_get_gc;
xml_parser_object_handlers.get_constructor = xml_parser_get_constructor;
xml_parser_object_handlers.clone_obj = NULL;
xml_parser_object_handlers.compare = zend_objects_not_comparable;
REGISTER_LONG_CONSTANT("XML_ERROR_NONE", XML_ERROR_NONE, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XML_ERROR_NO_MEMORY", XML_ERROR_NO_MEMORY, CONST_CS|CONST_PERSISTENT);

View File

@@ -1350,6 +1350,7 @@ static PHP_MINIT_FUNCTION(zlib)
inflate_context_object_handlers.free_obj = inflate_context_free_obj;
inflate_context_object_handlers.get_constructor = inflate_context_get_constructor;
inflate_context_object_handlers.clone_obj = NULL;
inflate_context_object_handlers.compare = zend_objects_not_comparable;
zend_class_entry deflate_ce;
INIT_CLASS_ENTRY(deflate_ce, "DeflateContext", class_DeflateContext_methods);
@@ -1364,6 +1365,7 @@ static PHP_MINIT_FUNCTION(zlib)
deflate_context_object_handlers.free_obj = deflate_context_free_obj;
deflate_context_object_handlers.get_constructor = deflate_context_get_constructor;
deflate_context_object_handlers.clone_obj = NULL;
deflate_context_object_handlers.compare = zend_objects_not_comparable;
REGISTER_LONG_CONSTANT("FORCE_GZIP", PHP_ZLIB_ENCODING_GZIP, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FORCE_DEFLATE", PHP_ZLIB_ENCODING_DEFLATE, CONST_CS|CONST_PERSISTENT);