Skip to content

Commit ce2dfa5

Browse files
authored
mark password as a sensitive param for 8.2 (#516)
* mark password as a sensitive param for 8.2
1 parent fc388e6 commit ce2dfa5

4 files changed

+63
-17
lines changed

Diff for: php_memcached.c

+3-4
Original file line numberDiff line numberDiff line change
@@ -3898,6 +3898,7 @@ PHP_METHOD(MemcachedServer, on)
38983898
#if PHP_VERSION_ID < 80000
38993899
#include "php_memcached_legacy_arginfo.h"
39003900
#else
3901+
#include "zend_attributes.h"
39013902
#include "php_memcached_arginfo.h"
39023903
#endif
39033904

@@ -4254,8 +4255,7 @@ PHP_MINIT_FUNCTION(memcached)
42544255

42554256
le_memc = zend_register_list_destructors_ex(NULL, php_memc_dtor, "Memcached persistent connection", module_number);
42564257

4257-
INIT_CLASS_ENTRY(ce, "Memcached", class_Memcached_methods);
4258-
memcached_ce = zend_register_internal_class(&ce);
4258+
memcached_ce = register_class_Memcached();
42594259
memcached_ce->create_object = php_memc_object_new;
42604260

42614261
#ifdef HAVE_MEMCACHED_PROTOCOL
@@ -4264,8 +4264,7 @@ PHP_MINIT_FUNCTION(memcached)
42644264
memcached_server_object_handlers.clone_obj = NULL;
42654265
memcached_server_object_handlers.free_obj = php_memc_server_free_storage;
42664266

4267-
INIT_CLASS_ENTRY(ce, "MemcachedServer", class_MemcachedServer_methods);
4268-
memcached_server_ce = zend_register_internal_class(&ce);
4267+
memcached_server_ce = register_class_MemcachedServer();
42694268
memcached_server_ce->create_object = php_memc_server_new;
42704269
#endif
42714270

Diff for: php_memcached.stub.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
/**
44
* @generate-function-entries
55
* @generate-legacy-arginfo
6+
* @generate-class-entries
67
*/
78

8-
99
class Memcached {
1010

1111
public function __construct(?string $persistent_id=null, ?callable $callback=null, ?string $connection_str=null) {}
@@ -75,7 +75,7 @@ public function setOption(int $option, mixed $value): bool {}
7575
public function setOptions(array $options): bool {}
7676
public function setBucket(array $host_map, ?array $forward_map, int $replicas): bool {}
7777
#ifdef HAVE_MEMCACHED_SASL
78-
public function setSaslAuthData(string $username, string $password): bool {}
78+
public function setSaslAuthData(string $username, #[\SensitiveParameter] string $password): bool {}
7979
#endif
8080

8181
#ifdef HAVE_MEMCACHED_SET_ENCODING_KEY
@@ -86,7 +86,7 @@ public function isPristine(): bool {}
8686
public function checkKey(string $key): bool {}
8787
}
8888

89-
#ifdef HAVE_MEMCACHED_PROTOCOL
89+
#if defined(HAVE_MEMCACHED_PROTOCOL)
9090
class MemcachedServer {
9191

9292
public function run(string $address): bool {}

Diff for: php_memcached_arginfo.h

+32-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 3f4694d4e1f3d1647a832acd8539b056b2ab5e7a */
2+
* Stub hash: 0964c9bfee903e59b63e5a16bd8b6611d827b151 */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Memcached___construct, 0, 0, 0)
55
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, persistent_id, IS_STRING, 1, "null")
@@ -406,12 +406,39 @@ static const zend_function_entry class_Memcached_methods[] = {
406406
};
407407

408408

409-
static const zend_function_entry class_MemcachedServer_methods[] = {
410409
#if defined(HAVE_MEMCACHED_PROTOCOL)
410+
static const zend_function_entry class_MemcachedServer_methods[] = {
411411
ZEND_ME(MemcachedServer, run, arginfo_class_MemcachedServer_run, ZEND_ACC_PUBLIC)
412-
#endif
413-
#if defined(HAVE_MEMCACHED_PROTOCOL)
414412
ZEND_ME(MemcachedServer, on, arginfo_class_MemcachedServer_on, ZEND_ACC_PUBLIC)
415-
#endif
416413
ZEND_FE_END
417414
};
415+
#endif
416+
417+
static zend_class_entry *register_class_Memcached(void)
418+
{
419+
zend_class_entry ce, *class_entry;
420+
421+
INIT_CLASS_ENTRY(ce, "Memcached", class_Memcached_methods);
422+
class_entry = zend_register_internal_class_ex(&ce, NULL);
423+
#if (PHP_VERSION_ID >= 80200)
424+
425+
#if defined(HAVE_MEMCACHED_SASL)
426+
427+
zend_add_parameter_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "setsaslauthdata", sizeof("setsaslauthdata") - 1), 1, ZSTR_KNOWN(ZEND_STR_SENSITIVEPARAMETER), 0);
428+
#endif
429+
#endif
430+
431+
return class_entry;
432+
}
433+
434+
#if defined(HAVE_MEMCACHED_PROTOCOL)
435+
static zend_class_entry *register_class_MemcachedServer(void)
436+
{
437+
zend_class_entry ce, *class_entry;
438+
439+
INIT_CLASS_ENTRY(ce, "MemcachedServer", class_MemcachedServer_methods);
440+
class_entry = zend_register_internal_class_ex(&ce, NULL);
441+
442+
return class_entry;
443+
}
444+
#endif

Diff for: php_memcached_legacy_arginfo.h

+25-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 3f4694d4e1f3d1647a832acd8539b056b2ab5e7a */
2+
* Stub hash: 0964c9bfee903e59b63e5a16bd8b6611d827b151 */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Memcached___construct, 0, 0, 0)
55
ZEND_ARG_INFO(0, persistent_id)
@@ -402,12 +402,32 @@ static const zend_function_entry class_Memcached_methods[] = {
402402
};
403403

404404

405-
static const zend_function_entry class_MemcachedServer_methods[] = {
406405
#if defined(HAVE_MEMCACHED_PROTOCOL)
406+
static const zend_function_entry class_MemcachedServer_methods[] = {
407407
ZEND_ME(MemcachedServer, run, arginfo_class_MemcachedServer_run, ZEND_ACC_PUBLIC)
408-
#endif
409-
#if defined(HAVE_MEMCACHED_PROTOCOL)
410408
ZEND_ME(MemcachedServer, on, arginfo_class_MemcachedServer_on, ZEND_ACC_PUBLIC)
411-
#endif
412409
ZEND_FE_END
413410
};
411+
#endif
412+
413+
static zend_class_entry *register_class_Memcached(void)
414+
{
415+
zend_class_entry ce, *class_entry;
416+
417+
INIT_CLASS_ENTRY(ce, "Memcached", class_Memcached_methods);
418+
class_entry = zend_register_internal_class_ex(&ce, NULL);
419+
420+
return class_entry;
421+
}
422+
423+
#if defined(HAVE_MEMCACHED_PROTOCOL)
424+
static zend_class_entry *register_class_MemcachedServer(void)
425+
{
426+
zend_class_entry ce, *class_entry;
427+
428+
INIT_CLASS_ENTRY(ce, "MemcachedServer", class_MemcachedServer_methods);
429+
class_entry = zend_register_internal_class_ex(&ce, NULL);
430+
431+
return class_entry;
432+
}
433+
#endif

0 commit comments

Comments
 (0)