diff options
author | Remi Collet <remi@remirepo.net> | 2022-07-04 15:27:20 +0300 |
---|---|---|
committer | Remi Collet <remi@php.net> | 2022-07-18 14:45:45 +0300 |
commit | 3675f442e413bd864c12787c3b383b110ed26963 (patch) | |
tree | eb67a42747b288260f88fd87db18dc36f42d7ddb | |
parent | 0f1ca0ccf815352d79e716dac49b854491ecc994 (diff) |
mark auth param as sensitive for PHP 8.2
refactor MINIT (split in each class sources file)
use @generate-class-entries in stub files
add RedisException and RedisClusterException in stub files
-rw-r--r-- | library.h | 3 | ||||
-rw-r--r-- | redis.c | 40 | ||||
-rw-r--r-- | redis.stub.php | 4 | ||||
-rw-r--r-- | redis_arginfo.h | 27 | ||||
-rw-r--r-- | redis_array.c | 9 | ||||
-rw-r--r-- | redis_array.h | 6 | ||||
-rw-r--r-- | redis_array.stub.php | 1 | ||||
-rw-r--r-- | redis_array_arginfo.h | 12 | ||||
-rw-r--r-- | redis_array_legacy_arginfo.h | 12 | ||||
-rw-r--r-- | redis_cluster.c | 17 | ||||
-rw-r--r-- | redis_cluster.h | 13 | ||||
-rw-r--r-- | redis_cluster.stub.php | 4 | ||||
-rw-r--r-- | redis_cluster_arginfo.h | 27 | ||||
-rw-r--r-- | redis_cluster_legacy_arginfo.h | 27 | ||||
-rw-r--r-- | redis_legacy_arginfo.h | 27 | ||||
-rw-r--r-- | redis_sentinel.c | 9 | ||||
-rw-r--r-- | redis_sentinel.h | 3 | ||||
-rw-r--r-- | redis_sentinel.stub.php | 2 | ||||
-rw-r--r-- | redis_sentinel_arginfo.h | 12 | ||||
-rw-r--r-- | redis_sentinel_legacy_arginfo.h | 12 |
20 files changed, 208 insertions, 59 deletions
@@ -35,6 +35,9 @@ #define REDIS_VALUE_EXCEPTION(m) zend_value_error(m) #endif +#if PHP_VERSION_ID < 80200 +#define zend_mark_function_parameter_as_sensitive(a,b,c) +#endif void redis_register_persistent_resource(zend_string *id, void *ptr, int le_id); void free_reply_callbacks(RedisSock *redis_sock); @@ -52,17 +52,13 @@ extern ps_module ps_mod_redis; extern ps_module ps_mod_redis_cluster; #endif -extern zend_class_entry *redis_array_ce; -extern zend_class_entry *redis_cluster_ce; -extern zend_class_entry *redis_cluster_exception_ce; -extern zend_class_entry *redis_sentinel_ce; - zend_class_entry *redis_ce; zend_class_entry *redis_exception_ce; #if PHP_VERSION_ID < 80000 #include "redis_legacy_arginfo.h" #else +#include "zend_attributes.h" #include "redis_arginfo.h" #endif @@ -440,14 +436,6 @@ static PHP_GINIT_FUNCTION(redis) PHP_MINIT_FUNCTION(redis) { struct timeval tv; - - zend_class_entry redis_class_entry; - zend_class_entry redis_array_class_entry; - zend_class_entry redis_cluster_class_entry; - zend_class_entry redis_sentinel_class_entry; - zend_class_entry redis_exception_class_entry; - zend_class_entry redis_cluster_exception_class_entry; - zend_class_entry *exception_ce = NULL; /* Seed random generator (for RedisCluster failover) */ @@ -457,24 +445,17 @@ PHP_MINIT_FUNCTION(redis) REGISTER_INI_ENTRIES(); /* Redis class */ - INIT_CLASS_ENTRY(redis_class_entry, "Redis", redis_get_methods()); - redis_ce = zend_register_internal_class(&redis_class_entry); + redis_ce = register_class_Redis(); redis_ce->create_object = create_redis_object; /* RedisArray class */ - INIT_CLASS_ENTRY(redis_array_class_entry, "RedisArray", redis_array_get_methods()); - redis_array_ce = zend_register_internal_class(&redis_array_class_entry); - redis_array_ce->create_object = create_redis_array_object; + ZEND_MINIT(redis_array)(INIT_FUNC_ARGS_PASSTHRU); /* RedisCluster class */ - INIT_CLASS_ENTRY(redis_cluster_class_entry, "RedisCluster", redis_cluster_get_methods()); - redis_cluster_ce = zend_register_internal_class(&redis_cluster_class_entry); - redis_cluster_ce->create_object = create_cluster_context; + ZEND_MINIT(redis_cluster)(INIT_FUNC_ARGS_PASSTHRU); /* RedisSentinel class */ - INIT_CLASS_ENTRY(redis_sentinel_class_entry, "RedisSentinel", redis_sentinel_get_methods()); - redis_sentinel_ce = zend_register_internal_class(&redis_sentinel_class_entry); - redis_sentinel_ce->create_object = create_sentinel_object; + ZEND_MINIT(redis_sentinel)(INIT_FUNC_ARGS_PASSTHRU); /* Register our cluster cache list item */ le_cluster_slot_cache = zend_register_list_destructors_ex(NULL, cluster_cache_dtor, @@ -488,16 +469,7 @@ PHP_MINIT_FUNCTION(redis) } /* RedisException class */ - INIT_CLASS_ENTRY(redis_exception_class_entry, "RedisException", NULL); - redis_exception_ce = zend_register_internal_class_ex( - &redis_exception_class_entry, - exception_ce); - - /* RedisClusterException class */ - INIT_CLASS_ENTRY(redis_cluster_exception_class_entry, - "RedisClusterException", NULL); - redis_cluster_exception_ce = zend_register_internal_class_ex( - &redis_cluster_exception_class_entry, exception_ce); + redis_exception_ce = register_class_RedisException(exception_ce); /* Add shared class constants to Redis and RedisCluster objects */ add_class_constants(redis_ce, 0); diff --git a/redis.stub.php b/redis.stub.php index 93dd2730..67db1629 100644 --- a/redis.stub.php +++ b/redis.stub.php @@ -3,6 +3,7 @@ /** * @generate-function-entries * @generate-legacy-arginfo + * @generate-class-entries */ class Redis { @@ -34,6 +35,7 @@ class Redis { /** @return int|Redis */ public function append(string $key, mixed $value); + /** @sensitive-param $credentials **/ public function auth(mixed $credentials): bool; public function bgSave(): bool; @@ -553,3 +555,5 @@ public function persist(string $key): bool; public function zunionstore(string $dst, array $keys, array $weights = null, string $aggregate = null): int; } + +class RedisException extends RuntimeException {} diff --git a/redis_arginfo.h b/redis_arginfo.h index ea660631..8dc5a4c3 100644 --- a/redis_arginfo.h +++ b/redis_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: efcda1ed028d65d0b4848d32133dc0e32f17871f */ + * Stub hash: 0e9010a9567392f6f2a8ad7f1f5f09a28a086c45 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis___construct, 0, 0, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 0, "null") @@ -1436,3 +1436,28 @@ static const zend_function_entry class_Redis_methods[] = { ZEND_ME(Redis, zunionstore, arginfo_class_Redis_zunionstore, ZEND_ACC_PUBLIC) ZEND_FE_END }; + + +static const zend_function_entry class_RedisException_methods[] = { + ZEND_FE_END +}; + +static zend_class_entry *register_class_Redis(void) +{ + zend_class_entry ce, *class_entry; + + INIT_CLASS_ENTRY(ce, "Redis", class_Redis_methods); + class_entry = zend_register_internal_class_ex(&ce, NULL); + + return class_entry; +} + +static zend_class_entry *register_class_RedisException(zend_class_entry *class_entry_RuntimeException) +{ + zend_class_entry ce, *class_entry; + + INIT_CLASS_ENTRY(ce, "RedisException", class_RedisException_methods); + class_entry = zend_register_internal_class_ex(&ce, class_entry_RuntimeException); + + return class_entry; +} diff --git a/redis_array.c b/redis_array.c index 1c5f0970..53ad4eb2 100644 --- a/redis_array.c +++ b/redis_array.c @@ -40,12 +40,17 @@ zend_class_entry *redis_array_ce; #if PHP_VERSION_ID < 80000 #include "redis_array_legacy_arginfo.h" #else +#include "zend_attributes.h" #include "redis_array_arginfo.h" #endif -extern const zend_function_entry *redis_array_get_methods(void) +PHP_MINIT_FUNCTION(redis_array) { - return class_RedisArray_methods; + /* RedisSentinel class */ + redis_array_ce = register_class_RedisArray(); + redis_array_ce->create_object = create_redis_array_object; + + return SUCCESS; } static void diff --git a/redis_array.h b/redis_array.h index 1e70be33..4dea35a6 100644 --- a/redis_array.h +++ b/redis_array.h @@ -36,8 +36,8 @@ typedef struct RedisArray_ { struct RedisArray_ *prev; } RedisArray; -extern const zend_function_entry *redis_array_get_methods(void); -zend_object *create_redis_array_object(zend_class_entry *ce); -void free_redis_array_object(zend_object *object); +extern zend_class_entry *redis_array_ce; +extern PHP_MINIT_FUNCTION(redis_array); +extern zend_object *create_redis_array_object(zend_class_entry *ce); #endif diff --git a/redis_array.stub.php b/redis_array.stub.php index cab4ffc9..8fca8ab9 100644 --- a/redis_array.stub.php +++ b/redis_array.stub.php @@ -3,6 +3,7 @@ /** * @generate-function-entries * @generate-legacy-arginfo + * @generate-class-entries */ class RedisArray { diff --git a/redis_array_arginfo.h b/redis_array_arginfo.h index 3b426b36..bfacd086 100644 --- a/redis_array_arginfo.h +++ b/redis_array_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: db47879ea03ea74832fe777fcc5d834ea554bb4a */ + * Stub hash: fb17c785beccf1dbeedaa48afb4aa7d48fd8b655 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_RedisArray___call, 0, 2, IS_MIXED, 0) ZEND_ARG_TYPE_INFO(0, function_name, IS_STRING, 0) @@ -176,3 +176,13 @@ static const zend_function_entry class_RedisArray_methods[] = { ZEND_ME(RedisArray, zscan, arginfo_class_RedisArray_zscan, ZEND_ACC_PUBLIC) ZEND_FE_END }; + +static zend_class_entry *register_class_RedisArray(void) +{ + zend_class_entry ce, *class_entry; + + INIT_CLASS_ENTRY(ce, "RedisArray", class_RedisArray_methods); + class_entry = zend_register_internal_class_ex(&ce, NULL); + + return class_entry; +} diff --git a/redis_array_legacy_arginfo.h b/redis_array_legacy_arginfo.h index 9c62aac5..1f2174ef 100644 --- a/redis_array_legacy_arginfo.h +++ b/redis_array_legacy_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: db47879ea03ea74832fe777fcc5d834ea554bb4a */ + * Stub hash: fb17c785beccf1dbeedaa48afb4aa7d48fd8b655 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisArray___call, 0, 0, 2) ZEND_ARG_INFO(0, function_name) @@ -173,3 +173,13 @@ static const zend_function_entry class_RedisArray_methods[] = { ZEND_ME(RedisArray, zscan, arginfo_class_RedisArray_zscan, ZEND_ACC_PUBLIC) ZEND_FE_END }; + +static zend_class_entry *register_class_RedisArray(void) +{ + zend_class_entry ce, *class_entry; + + INIT_CLASS_ENTRY(ce, "RedisArray", class_RedisArray_methods); + class_entry = zend_register_internal_class_ex(&ce, NULL); + + return class_entry; +} diff --git a/redis_cluster.c b/redis_cluster.c index 5634560f..e3451899 100644 --- a/redis_cluster.c +++ b/redis_cluster.c @@ -38,12 +38,25 @@ zend_class_entry *redis_cluster_exception_ce; #if PHP_VERSION_ID < 80000 #include "redis_cluster_legacy_arginfo.h" #else +#include "zend_attributes.h" #include "redis_cluster_arginfo.h" #endif -extern const zend_function_entry *redis_cluster_get_methods(void) +PHP_MINIT_FUNCTION(redis_cluster) { - return class_RedisCluster_methods; + zend_class_entry *exception_ce = NULL; + + redis_cluster_ce = register_class_RedisCluster(); + redis_cluster_ce->create_object = create_cluster_context; + + /* Base Exception class */ + exception_ce = zend_hash_str_find_ptr(CG(class_table), "RuntimeException", sizeof("RuntimeException") - 1); + if (exception_ce == NULL) { + exception_ce = zend_exception_get_default(); + } + redis_cluster_exception_ce = register_class_RedisClusterException(exception_ce); + + return SUCCESS; } /* Handlers for RedisCluster */ diff --git a/redis_cluster.h b/redis_cluster.h index d8e62e7f..01781416 100644 --- a/redis_cluster.h +++ b/redis_cluster.h @@ -91,12 +91,11 @@ } \ resp_func(INTERNAL_FUNCTION_PARAM_PASSTHRU, c, ctx); -extern const zend_function_entry *redis_cluster_get_methods(void); - -/* Create cluster context */ -zend_object *create_cluster_context(zend_class_entry *class_type); +#endif -/* Free cluster context struct */ -void free_cluster_context(zend_object *object); +extern zend_class_entry *redis_cluster_ce; +extern zend_class_entry *redis_cluster_exception_ce; +extern PHP_MINIT_FUNCTION(redis_cluster); +extern zend_object * create_cluster_context(zend_class_entry *class_type); +extern void free_cluster_context(zend_object *object); -#endif diff --git a/redis_cluster.stub.php b/redis_cluster.stub.php index 2fe512fd..3c53d6e9 100644 --- a/redis_cluster.stub.php +++ b/redis_cluster.stub.php @@ -3,10 +3,12 @@ /** * @generate-function-entries * @generate-legacy-arginfo + * @generate-class-entries */ class RedisCluster { + /** @sensitive-param $auth **/ public function __construct(string|null $name, array $seeds = NULL, int|float $timeout = 0, int|float $read_timeout = 0, bool $persistant = false, mixed $auth = NULL, array $context = NULL); public function _compress(string $value): string; @@ -389,3 +391,5 @@ class RedisCluster { public function zunionstore(string $key, array $keys, array $weights = null, string $aggregate = null): int; } + +class RedisClusterException extends RuntimeException {} diff --git a/redis_cluster_arginfo.h b/redis_cluster_arginfo.h index 95945fc3..24f4ca47 100644 --- a/redis_cluster_arginfo.h +++ b/redis_cluster_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 8029a0d6df2bbd9cf5d140ff8d9efcc4de2a5bcc */ + * Stub hash: 72e55bab630cd2a6dd6620d77e97ec0716d667b1 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster___construct, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, name, IS_STRING, 1) @@ -1226,3 +1226,28 @@ static const zend_function_entry class_RedisCluster_methods[] = { ZEND_ME(RedisCluster, zunionstore, arginfo_class_RedisCluster_zunionstore, ZEND_ACC_PUBLIC) ZEND_FE_END }; + + +static const zend_function_entry class_RedisClusterException_methods[] = { + ZEND_FE_END +}; + +static zend_class_entry *register_class_RedisCluster(void) +{ + zend_class_entry ce, *class_entry; + + INIT_CLASS_ENTRY(ce, "RedisCluster", class_RedisCluster_methods); + class_entry = zend_register_internal_class_ex(&ce, NULL); + + return class_entry; +} + +static zend_class_entry *register_class_RedisClusterException(zend_class_entry *class_entry_RuntimeException) +{ + zend_class_entry ce, *class_entry; + + INIT_CLASS_ENTRY(ce, "RedisClusterException", class_RedisClusterException_methods); + class_entry = zend_register_internal_class_ex(&ce, class_entry_RuntimeException); + + return class_entry; +} diff --git a/redis_cluster_legacy_arginfo.h b/redis_cluster_legacy_arginfo.h index bc07b117..aec77bf9 100644 --- a/redis_cluster_legacy_arginfo.h +++ b/redis_cluster_legacy_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 8029a0d6df2bbd9cf5d140ff8d9efcc4de2a5bcc */ + * Stub hash: 72e55bab630cd2a6dd6620d77e97ec0716d667b1 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster___construct, 0, 0, 1) ZEND_ARG_INFO(0, name) @@ -1114,3 +1114,28 @@ static const zend_function_entry class_RedisCluster_methods[] = { ZEND_ME(RedisCluster, zunionstore, arginfo_class_RedisCluster_zunionstore, ZEND_ACC_PUBLIC) ZEND_FE_END }; + + +static const zend_function_entry class_RedisClusterException_methods[] = { + ZEND_FE_END +}; + +static zend_class_entry *register_class_RedisCluster(void) +{ + zend_class_entry ce, *class_entry; + + INIT_CLASS_ENTRY(ce, "RedisCluster", class_RedisCluster_methods); + class_entry = zend_register_internal_class_ex(&ce, NULL); + + return class_entry; +} + +static zend_class_entry *register_class_RedisClusterException(zend_class_entry *class_entry_RuntimeException) +{ + zend_class_entry ce, *class_entry; + + INIT_CLASS_ENTRY(ce, "RedisClusterException", class_RedisClusterException_methods); + class_entry = zend_register_internal_class_ex(&ce, class_entry_RuntimeException); + + return class_entry; +} diff --git a/redis_legacy_arginfo.h b/redis_legacy_arginfo.h index 622d61cb..83750374 100644 --- a/redis_legacy_arginfo.h +++ b/redis_legacy_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: efcda1ed028d65d0b4848d32133dc0e32f17871f */ + * Stub hash: 0e9010a9567392f6f2a8ad7f1f5f09a28a086c45 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis___construct, 0, 0, 0) ZEND_ARG_INFO(0, options) @@ -1332,3 +1332,28 @@ static const zend_function_entry class_Redis_methods[] = { ZEND_ME(Redis, zunionstore, arginfo_class_Redis_zunionstore, ZEND_ACC_PUBLIC) ZEND_FE_END }; + + +static const zend_function_entry class_RedisException_methods[] = { + ZEND_FE_END +}; + +static zend_class_entry *register_class_Redis(void) +{ + zend_class_entry ce, *class_entry; + + INIT_CLASS_ENTRY(ce, "Redis", class_Redis_methods); + class_entry = zend_register_internal_class_ex(&ce, NULL); + + return class_entry; +} + +static zend_class_entry *register_class_RedisException(zend_class_entry *class_entry_RuntimeException) +{ + zend_class_entry ce, *class_entry; + + INIT_CLASS_ENTRY(ce, "RedisException", class_RedisException_methods); + class_entry = zend_register_internal_class_ex(&ce, class_entry_RuntimeException); + + return class_entry; +} diff --git a/redis_sentinel.c b/redis_sentinel.c index 632975cd..5aa44420 100644 --- a/redis_sentinel.c +++ b/redis_sentinel.c @@ -26,12 +26,17 @@ extern zend_class_entry *redis_exception_ce; #if PHP_VERSION_ID < 80000 #include "redis_sentinel_legacy_arginfo.h" #else +#include "zend_attributes.h" #include "redis_sentinel_arginfo.h" #endif -extern const zend_function_entry *redis_sentinel_get_methods(void) +PHP_MINIT_FUNCTION(redis_sentinel) { - return class_RedisSentinel_methods; + /* RedisSentinel class */ + redis_sentinel_ce = register_class_RedisSentinel(); + redis_sentinel_ce->create_object = create_sentinel_object; + + return SUCCESS; } PHP_METHOD(RedisSentinel, __construct) diff --git a/redis_sentinel.h b/redis_sentinel.h index a24c5c0b..0878b62d 100644 --- a/redis_sentinel.h +++ b/redis_sentinel.h @@ -5,6 +5,7 @@ #define PHP_REDIS_SENTINEL_VERSION "0.1" -extern const zend_function_entry *redis_sentinel_get_methods(void); +extern zend_class_entry *redis_sentinel_ce; +extern PHP_MINIT_FUNCTION(redis_sentinel); #endif /* REDIS_SENTINEL_H */ diff --git a/redis_sentinel.stub.php b/redis_sentinel.stub.php index 58df4838..313040f9 100644 --- a/redis_sentinel.stub.php +++ b/redis_sentinel.stub.php @@ -3,10 +3,12 @@ /** * @generate-function-entries * @generate-legacy-arginfo + * @generate-class-entries */ class RedisSentinel { + /** @sensitive-param $auth **/ public function __construct(string $host, int $port = 26379, float $timeout = 0, mixed $persistent = NULL, int $retry_interval = 0, float $read_timeout = 0, mixed $auth = NULL); /** @return bool|RedisSentinel */ diff --git a/redis_sentinel_arginfo.h b/redis_sentinel_arginfo.h index 2afdd4e1..ac951783 100644 --- a/redis_sentinel_arginfo.h +++ b/redis_sentinel_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: deae7b4a55435fb2ab39f314544064a34c56d218 */ + * Stub hash: 4e8243076e2c4470473a08456ff20be9f230ee74 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisSentinel___construct, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, host, IS_STRING, 0) @@ -69,3 +69,13 @@ static const zend_function_entry class_RedisSentinel_methods[] = { ZEND_ME(RedisSentinel, slaves, arginfo_class_RedisSentinel_slaves, ZEND_ACC_PUBLIC) ZEND_FE_END }; + +static zend_class_entry *register_class_RedisSentinel(void) +{ + zend_class_entry ce, *class_entry; + + INIT_CLASS_ENTRY(ce, "RedisSentinel", class_RedisSentinel_methods); + class_entry = zend_register_internal_class_ex(&ce, NULL); + + return class_entry; +} diff --git a/redis_sentinel_legacy_arginfo.h b/redis_sentinel_legacy_arginfo.h index 8f35e6c1..e65d841e 100644 --- a/redis_sentinel_legacy_arginfo.h +++ b/redis_sentinel_legacy_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: deae7b4a55435fb2ab39f314544064a34c56d218 */ + * Stub hash: 4e8243076e2c4470473a08456ff20be9f230ee74 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisSentinel___construct, 0, 0, 1) ZEND_ARG_INFO(0, host) @@ -68,3 +68,13 @@ static const zend_function_entry class_RedisSentinel_methods[] = { ZEND_ME(RedisSentinel, slaves, arginfo_class_RedisSentinel_slaves, ZEND_ACC_PUBLIC) ZEND_FE_END }; + +static zend_class_entry *register_class_RedisSentinel(void) +{ + zend_class_entry ce, *class_entry; + + INIT_CLASS_ENTRY(ce, "RedisSentinel", class_RedisSentinel_methods); + class_entry = zend_register_internal_class_ex(&ce, NULL); + + return class_entry; +} |