From 62147b1f0f7d7b50de74f1cea02cf48aa55c269c Mon Sep 17 00:00:00 2001 From: matyhtf Date: Fri, 1 Sep 2017 13:17:38 +0800 Subject: [PATCH] Prohibit serialization --- php_swoole.h | 1 + swoole.c | 5 +++++ swoole_atomic.c | 2 ++ swoole_buffer.c | 2 ++ swoole_http_server.c | 4 ++++ swoole_server.c | 3 ++- swoole_table.c | 2 ++ 7 files changed, 18 insertions(+), 1 deletion(-) diff --git a/php_swoole.h b/php_swoole.h index 12de0280da7..12bdb3f5d60 100644 --- a/php_swoole.h +++ b/php_swoole.h @@ -250,6 +250,7 @@ PHP_FUNCTION(swoole_cpu_num); PHP_FUNCTION(swoole_set_process_name); PHP_FUNCTION(swoole_get_local_ip); PHP_FUNCTION(swoole_get_local_mac); +PHP_FUNCTION(swoole_unsupport_serialize); //--------------------------------------------------------- // swoole_server diff --git a/swoole.c b/swoole.c index bee69f6702c..73588c2a743 100644 --- a/swoole.c +++ b/swoole.c @@ -1070,6 +1070,11 @@ PHP_FUNCTION(swoole_version) SW_RETURN_STRING(swoole_version, 1); } +PHP_FUNCTION(swoole_unsupport_serialize) +{ + zend_throw_exception_ex(swoole_exception_class_entry_ptr, 0, "cannot serialize or unserialize."); +} + static PHP_FUNCTION(swoole_last_error) { RETURN_LONG(SwooleG.error); diff --git a/swoole_atomic.c b/swoole_atomic.c index 6987a9a2d8d..9f9a9924dcf 100644 --- a/swoole_atomic.c +++ b/swoole_atomic.c @@ -115,6 +115,8 @@ static const zend_function_entry swoole_atomic_methods[] = PHP_ME(swoole_atomic, wait, arginfo_swoole_atomic_wait, ZEND_ACC_PUBLIC) PHP_ME(swoole_atomic, wakeup, arginfo_swoole_atomic_waitup, ZEND_ACC_PUBLIC) PHP_ME(swoole_atomic, cmpset, arginfo_swoole_atomic_cmpset, ZEND_ACC_PUBLIC) + PHP_FALIAS(__sleep, swoole_unsupport_serialize, NULL) + PHP_FALIAS(__wakeup, swoole_unsupport_serialize, NULL) PHP_FE_END }; diff --git a/swoole_buffer.c b/swoole_buffer.c index e3de0fc110d..a6ac229d949 100644 --- a/swoole_buffer.c +++ b/swoole_buffer.c @@ -70,6 +70,8 @@ static const zend_function_entry swoole_buffer_methods[] = PHP_ME(swoole_buffer, expand, arginfo_swoole_buffer_expand, ZEND_ACC_PUBLIC) PHP_ME(swoole_buffer, recycle, arginfo_swoole_buffer_void, ZEND_ACC_PUBLIC) PHP_ME(swoole_buffer, clear, arginfo_swoole_buffer_void, ZEND_ACC_PUBLIC) + PHP_FALIAS(__sleep, swoole_unsupport_serialize, NULL) + PHP_FALIAS(__wakeup, swoole_unsupport_serialize, NULL) PHP_FE_END }; diff --git a/swoole_http_server.c b/swoole_http_server.c index 52e2ef69b1d..8c774ff0328 100644 --- a/swoole_http_server.c +++ b/swoole_http_server.c @@ -380,6 +380,8 @@ const zend_function_entry swoole_http_server_methods[] = const zend_function_entry swoole_http_request_methods[] = { PHP_ME(swoole_http_request, rawcontent, arginfo_swoole_http_void, ZEND_ACC_PUBLIC) + PHP_FALIAS(__sleep, swoole_unsupport_serialize, NULL) + PHP_FALIAS(__wakeup, swoole_unsupport_serialize, NULL) PHP_ME(swoole_http_request, __destruct, arginfo_swoole_http_void, ZEND_ACC_PUBLIC | ZEND_ACC_DTOR) PHP_FE_END }; @@ -400,6 +402,8 @@ const zend_function_entry swoole_http_response_methods[] = PHP_ME(swoole_http_response, write, arginfo_swoole_http_response_write, ZEND_ACC_PUBLIC) PHP_ME(swoole_http_response, end, arginfo_swoole_http_response_end, ZEND_ACC_PUBLIC) PHP_ME(swoole_http_response, sendfile, arginfo_swoole_http_response_sendfile, ZEND_ACC_PUBLIC) + PHP_FALIAS(__sleep, swoole_unsupport_serialize, NULL) + PHP_FALIAS(__wakeup, swoole_unsupport_serialize, NULL) PHP_ME(swoole_http_response, __destruct, arginfo_swoole_http_void, ZEND_ACC_PUBLIC | ZEND_ACC_DTOR) PHP_FE_END }; diff --git a/swoole_server.c b/swoole_server.c index f003c4667c7..28b40a558a7 100644 --- a/swoole_server.c +++ b/swoole_server.c @@ -1543,7 +1543,6 @@ PHP_METHOD(swoole_server, __construct) zval *ports; SW_ALLOC_INIT_ZVAL(ports); array_init(ports); - zend_update_property(swoole_server_class_entry_ptr, server_object, ZEND_STRL("ports"), ports TSRMLS_CC); server_port_list.zports = ports; swListenPort *ls; @@ -1551,6 +1550,8 @@ PHP_METHOD(swoole_server, __construct) { php_swoole_server_add_port(ls TSRMLS_CC); } + + zend_update_property(swoole_server_class_entry_ptr, server_object, ZEND_STRL("ports"), ports TSRMLS_CC); } PHP_METHOD(swoole_server, __destruct) diff --git a/swoole_table.c b/swoole_table.c index eace017d56d..f9efa3e8d6e 100644 --- a/swoole_table.c +++ b/swoole_table.c @@ -138,6 +138,8 @@ static const zend_function_entry swoole_table_methods[] = PHP_ME(swoole_table, offsetGet, arginfo_swoole_table_offsetGet, ZEND_ACC_PUBLIC) PHP_ME(swoole_table, offsetSet, arginfo_swoole_table_offsetSet, ZEND_ACC_PUBLIC) PHP_ME(swoole_table, offsetUnset, arginfo_swoole_table_offsetUnset, ZEND_ACC_PUBLIC) + PHP_FALIAS(__sleep, swoole_unsupport_serialize, NULL) + PHP_FALIAS(__wakeup, swoole_unsupport_serialize, NULL) #ifdef HAVE_PCRE PHP_ME(swoole_table, rewind, arginfo_swoole_table_void, ZEND_ACC_PUBLIC) PHP_ME(swoole_table, next, arginfo_swoole_table_void, ZEND_ACC_PUBLIC)