Skip to content

Commit 8f1dd9b

Browse files
committed
Zend: introduce gcc strub attribute.
exists since gcc 14.x, allow to zero stack/pointer local variables, a call or a callable (function pointers).
1 parent dfff6ac commit 8f1dd9b

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

Zend/zend_portability.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,14 @@ extern "C++" {
759759
# define ZEND_INDIRECT_RETURN
760760
#endif
761761

762+
#if __has_attribute(strub)
763+
# define ZEND_STRUB __attribute__((strub))
764+
# define ZEND_STRUB_OPT(o) __attribute__((strub(o)))
765+
#else
766+
# define ZEND_STRUB
767+
# define ZEND_STRUB_OPT(o)
768+
#endif
769+
762770
#define __ZEND_DO_PRAGMA(x) _Pragma(#x)
763771
#define _ZEND_DO_PRAGMA(x) __ZEND_DO_PRAGMA(x)
764772
#if defined(__clang__)

ext/standard/password.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ void php_password_algo_unregister(const char *ident) {
4949
static int php_password_salt_to64(const char *str, const size_t str_len, const size_t out_len, char *ret) /* {{{ */
5050
{
5151
size_t pos = 0;
52-
zend_string *buffer;
52+
zend_string ZEND_STRUB *buffer;
5353
if ((int) str_len < 0) {
5454
return FAILURE;
5555
}
@@ -76,7 +76,8 @@ static int php_password_salt_to64(const char *str, const size_t str_len, const s
7676

7777
static zend_string* php_password_make_salt(size_t length) /* {{{ */
7878
{
79-
zend_string *ret, *buffer;
79+
zend_string *ret;
80+
zend_string ZEND_STRUB *buffer;
8081

8182
if (length > (INT_MAX / 3)) {
8283
zend_value_error("Length is too large to safely generate");

0 commit comments

Comments
 (0)