Skip to content

Commit b63ea10

Browse files
committed
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.
1 parent cb9785a commit b63ea10

File tree

13 files changed

+17
-0
lines changed

13 files changed

+17
-0
lines changed

ext/curl/interface.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,6 +1200,7 @@ PHP_MINIT_FUNCTION(curl)
12001200
curl_object_handlers.get_constructor = curl_get_constructor;
12011201
curl_object_handlers.clone_obj = curl_clone_obj;
12021202
curl_object_handlers.cast_object = curl_cast_object;
1203+
curl_object_handlers.compare = zend_objects_not_comparable;
12031204

12041205
curl_multi_register_class(class_CurlMultiHandle_methods);
12051206
curl_share_register_class(class_CurlShareHandle_methods);

ext/curl/multi.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,4 +603,5 @@ void curl_multi_register_class(const zend_function_entry *method_entries) {
603603
curl_multi_handlers.get_constructor = curl_multi_get_constructor;
604604
curl_multi_handlers.clone_obj = NULL;
605605
curl_multi_handlers.cast_object = curl_cast_object;
606+
curl_multi_handlers.compare = zend_objects_not_comparable;
606607
}

ext/curl/share.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,4 +176,5 @@ void curl_share_register_class(const zend_function_entry *method_entries) {
176176
curl_share_handlers.free_obj = curl_share_free_obj;
177177
curl_share_handlers.get_constructor = curl_share_get_constructor;
178178
curl_share_handlers.clone_obj = NULL;
179+
curl_share_handlers.compare = zend_objects_not_comparable;
179180
}

ext/enchant/enchant.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ PHP_MINIT_FUNCTION(enchant)
199199
enchant_broker_handlers.offset = XtOffsetOf(enchant_broker, std);
200200
enchant_broker_handlers.free_obj = php_enchant_broker_free;
201201
enchant_broker_handlers.clone_obj = NULL;
202+
enchant_broker_handlers.compare = zend_objects_not_comparable;
202203

203204
INIT_CLASS_ENTRY(dce, "EnchantDictionary", class_EnchantDictionary_methods);
204205
enchant_dict_ce = zend_register_internal_class(&dce);
@@ -211,6 +212,7 @@ PHP_MINIT_FUNCTION(enchant)
211212
enchant_dict_handlers.offset = XtOffsetOf(enchant_dict, std);
212213
enchant_dict_handlers.free_obj = php_enchant_dict_free;
213214
enchant_dict_handlers.clone_obj = NULL;
215+
enchant_dict_handlers.compare = zend_objects_not_comparable;
214216

215217
REGISTER_LONG_CONSTANT("ENCHANT_MYSPELL", PHP_ENCHANT_MYSPELL, CONST_CS | CONST_PERSISTENT | CONST_DEPRECATED);
216218
REGISTER_LONG_CONSTANT("ENCHANT_ISPELL", PHP_ENCHANT_ISPELL, CONST_CS | CONST_PERSISTENT | CONST_DEPRECATED);

ext/gd/gd.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ static void php_gd_object_minit_helper()
232232
php_gd_image_object_handlers.clone_obj = NULL;
233233
php_gd_image_object_handlers.free_obj = php_gd_image_object_free;
234234
php_gd_image_object_handlers.get_constructor = php_gd_image_object_get_constructor;
235+
php_gd_image_object_handlers.compare = zend_objects_not_comparable;
235236
php_gd_image_object_handlers.offset = XtOffsetOf(php_gd_image_object, std);
236237
}
237238

ext/openssl/openssl.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,6 +1116,7 @@ PHP_MINIT_FUNCTION(openssl)
11161116
php_openssl_certificate_object_handlers.free_obj = php_openssl_certificate_free_obj;
11171117
php_openssl_certificate_object_handlers.get_constructor = php_openssl_certificate_get_constructor;
11181118
php_openssl_certificate_object_handlers.clone_obj = NULL;
1119+
php_openssl_certificate_object_handlers.compare = zend_objects_not_comparable;
11191120

11201121
zend_class_entry csr_ce;
11211122
INIT_CLASS_ENTRY(csr_ce, "OpenSSLCertificateSigningRequest", class_OpenSSLCertificateSigningRequest_methods);
@@ -1130,6 +1131,7 @@ PHP_MINIT_FUNCTION(openssl)
11301131
php_openssl_request_object_handlers.free_obj = php_openssl_request_free_obj;
11311132
php_openssl_request_object_handlers.get_constructor = php_openssl_request_get_constructor;
11321133
php_openssl_request_object_handlers.clone_obj = NULL;
1134+
php_openssl_request_object_handlers.compare = zend_objects_not_comparable;
11331135

11341136
zend_class_entry key_ce;
11351137
INIT_CLASS_ENTRY(key_ce, "OpenSSLAsymmetricKey", class_OpenSSLAsymmetricKey_methods);
@@ -1144,6 +1146,7 @@ PHP_MINIT_FUNCTION(openssl)
11441146
php_openssl_pkey_object_handlers.free_obj = php_openssl_pkey_free_obj;
11451147
php_openssl_pkey_object_handlers.get_constructor = php_openssl_pkey_get_constructor;
11461148
php_openssl_pkey_object_handlers.clone_obj = NULL;
1149+
php_openssl_pkey_object_handlers.compare = zend_objects_not_comparable;
11471150

11481151
#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined (LIBRESSL_VERSION_NUMBER)
11491152
OPENSSL_config(NULL);

ext/shmop/shmop.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ PHP_MINIT_FUNCTION(shmop)
121121
shmop_object_handlers.free_obj = shmop_free_obj;
122122
shmop_object_handlers.get_constructor = shmop_get_constructor;
123123
shmop_object_handlers.clone_obj = NULL;
124+
shmop_object_handlers.compare = zend_objects_not_comparable;
124125

125126
return SUCCESS;
126127
}

ext/sockets/sockets.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,7 @@ static PHP_MINIT_FUNCTION(sockets)
461461
address_info_object_handlers.free_obj = address_info_free_obj;
462462
address_info_object_handlers.get_constructor = address_info_get_constructor;
463463
address_info_object_handlers.clone_obj = NULL;
464+
address_info_object_handlers.compare = zend_objects_not_comparable;
464465

465466
REGISTER_LONG_CONSTANT("AF_UNIX", AF_UNIX, CONST_CS | CONST_PERSISTENT);
466467
REGISTER_LONG_CONSTANT("AF_INET", AF_INET, CONST_CS | CONST_PERSISTENT);

ext/sysvmsg/sysvmsg.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ PHP_MINIT_FUNCTION(sysvmsg)
121121
sysvmsg_queue_object_handlers.free_obj = sysvmsg_queue_free_obj;
122122
sysvmsg_queue_object_handlers.get_constructor = sysvmsg_queue_get_constructor;
123123
sysvmsg_queue_object_handlers.clone_obj = NULL;
124+
sysvmsg_queue_object_handlers.compare = zend_objects_not_comparable;
124125

125126
REGISTER_LONG_CONSTANT("MSG_IPC_NOWAIT", PHP_MSG_IPC_NOWAIT, CONST_PERSISTENT|CONST_CS);
126127
REGISTER_LONG_CONSTANT("MSG_EAGAIN", EAGAIN, CONST_PERSISTENT|CONST_CS);

ext/sysvsem/sysvsem.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ PHP_MINIT_FUNCTION(sysvsem)
164164
sysvsem_object_handlers.free_obj = sysvsem_free_obj;
165165
sysvsem_object_handlers.get_constructor = sysvsem_get_constructor;
166166
sysvsem_object_handlers.clone_obj = NULL;
167+
sysvsem_object_handlers.compare = zend_objects_not_comparable;
167168

168169
return SUCCESS;
169170
}

ext/sysvshm/sysvshm.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ PHP_MINIT_FUNCTION(sysvshm)
112112
sysvshm_object_handlers.free_obj = sysvshm_free_obj;
113113
sysvshm_object_handlers.get_constructor = sysvshm_get_constructor;
114114
sysvshm_object_handlers.clone_obj = NULL;
115+
sysvshm_object_handlers.compare = zend_objects_not_comparable;
115116

116117
if (cfg_get_long("sysvshm.init_mem", &php_sysvshm.init_mem) == FAILURE) {
117118
php_sysvshm.init_mem=10000;

ext/xml/xml.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ PHP_MINIT_FUNCTION(xml)
267267
xml_parser_object_handlers.get_gc = xml_parser_get_gc;
268268
xml_parser_object_handlers.get_constructor = xml_parser_get_constructor;
269269
xml_parser_object_handlers.clone_obj = NULL;
270+
xml_parser_object_handlers.compare = zend_objects_not_comparable;
270271

271272
REGISTER_LONG_CONSTANT("XML_ERROR_NONE", XML_ERROR_NONE, CONST_CS|CONST_PERSISTENT);
272273
REGISTER_LONG_CONSTANT("XML_ERROR_NO_MEMORY", XML_ERROR_NO_MEMORY, CONST_CS|CONST_PERSISTENT);

ext/zlib/zlib.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,6 +1350,7 @@ static PHP_MINIT_FUNCTION(zlib)
13501350
inflate_context_object_handlers.free_obj = inflate_context_free_obj;
13511351
inflate_context_object_handlers.get_constructor = inflate_context_get_constructor;
13521352
inflate_context_object_handlers.clone_obj = NULL;
1353+
inflate_context_object_handlers.compare = zend_objects_not_comparable;
13531354

13541355
zend_class_entry deflate_ce;
13551356
INIT_CLASS_ENTRY(deflate_ce, "DeflateContext", class_DeflateContext_methods);
@@ -1364,6 +1365,7 @@ static PHP_MINIT_FUNCTION(zlib)
13641365
deflate_context_object_handlers.free_obj = deflate_context_free_obj;
13651366
deflate_context_object_handlers.get_constructor = deflate_context_get_constructor;
13661367
deflate_context_object_handlers.clone_obj = NULL;
1368+
deflate_context_object_handlers.compare = zend_objects_not_comparable;
13671369

13681370
REGISTER_LONG_CONSTANT("FORCE_GZIP", PHP_ZLIB_ENCODING_GZIP, CONST_CS|CONST_PERSISTENT);
13691371
REGISTER_LONG_CONSTANT("FORCE_DEFLATE", PHP_ZLIB_ENCODING_DEFLATE, CONST_CS|CONST_PERSISTENT);

0 commit comments

Comments
 (0)