Skip to content

Commit f4e8df0

Browse files
ZEND_SECURE_ZERO
1 parent 1f4660e commit f4e8df0

8 files changed

+12
-12
lines changed

php7/memcache_ascii_protocol.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ static int mmc_server_read_value(mmc_t *mmc, mmc_request_t *request) /*
206206
static mmc_request_t *mmc_ascii_create_request() /* {{{ */
207207
{
208208
mmc_ascii_request_t *request = emalloc(sizeof(mmc_ascii_request_t));
209-
memset(request, 0, sizeof(*request));
209+
ZEND_SECURE_ZERO(request, sizeof(*request));
210210
return (mmc_request_t *)request;
211211
}
212212
/* }}} */
@@ -265,7 +265,7 @@ static int mmc_ascii_store(
265265
mmc_buffer_t buffer;
266266
request->parse = mmc_request_parse_response;
267267

268-
memset(&buffer, 0, sizeof(buffer));
268+
ZEND_SECURE_ZERO(&buffer, sizeof(buffer));
269269
status = mmc_pack_value(pool, &buffer, value, &flags);
270270

271271
if (status != MMC_OK) {

php7/memcache_binary_protocol.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ static inline void mmc_pack_header(mmc_request_header_t *header, uint8_t opcode,
436436
static mmc_request_t *mmc_binary_create_request() /* {{{ */
437437
{
438438
mmc_binary_request_t *request = emalloc(sizeof(mmc_binary_request_t));
439-
memset(request, 0, sizeof(mmc_binary_request_t));
439+
ZEND_SECURE_ZERO(request, sizeof(mmc_binary_request_t));
440440
return (mmc_request_t *)request;
441441
}
442442
/* }}} */

php7/memcache_consistent_hash.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ typedef struct mmc_consistent_state {
4747
void *mmc_consistent_create_state(mmc_hash_function_t *hash) /* {{{ */
4848
{
4949
mmc_consistent_state_t *state = emalloc(sizeof(mmc_consistent_state_t));
50-
memset(state, 0, sizeof(mmc_consistent_state_t));
50+
ZEND_SECURE_ZERO(state, sizeof(mmc_consistent_state_t));
5151
state->hash = hash;
5252
return state;
5353
}

php7/memcache_pool.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ MMC_POOL_INLINE void mmc_buffer_free(mmc_buffer_t *buffer) /* {{{ */
5454
if (buffer->value.c != NULL) {
5555
smart_string_free(&(buffer->value));
5656
}
57-
memset(buffer, 0, sizeof(*buffer));
57+
ZEND_SECURE_ZERO(buffer, sizeof(*buffer));
5858
}
5959
/* }}} */
6060

@@ -297,7 +297,7 @@ static void mmc_compress(mmc_pool_t *pool, mmc_buffer_t *buffer, const char *val
297297
prev = *buffer;
298298

299299
/* allocate space for prev header + result */
300-
memset(buffer, 0, sizeof(*buffer));
300+
ZEND_SECURE_ZERO(buffer, sizeof(*buffer));
301301
mmc_buffer_alloc(buffer, prev.value.len + result_len);
302302

303303
/* append prev header */
@@ -543,7 +543,7 @@ mmc_t *mmc_server_new(
543543
int persistent, double timeout, int retry_interval) /* {{{ */
544544
{
545545
mmc_t *mmc = pemalloc(sizeof(mmc_t), persistent);
546-
memset(mmc, 0, sizeof(*mmc));
546+
ZEND_SECURE_ZERO(mmc, sizeof(*mmc));
547547

548548
mmc->host = pemalloc(host_len + 1, persistent);
549549
memcpy(mmc->host, host, host_len);
@@ -851,7 +851,7 @@ static void mmc_pool_init_hash(mmc_pool_t *pool) /* {{{ */
851851
mmc_pool_t *mmc_pool_new() /* {{{ */
852852
{
853853
mmc_pool_t *pool = emalloc(sizeof(mmc_pool_t));
854-
memset(pool, 0, sizeof(*pool));
854+
ZEND_SECURE_ZERO(pool, sizeof(*pool));
855855

856856
switch (MEMCACHE_G(protocol)) {
857857
case MMC_BINARY_PROTOCOL:

php7/memcache_pool.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ typedef struct mmc_buffer {
124124
unsigned int idx; /* current index */
125125
} mmc_buffer_t;
126126

127-
#define mmc_buffer_release(b) memset((b), 0, sizeof(*(b)))
127+
#define mmc_buffer_release(b) ZEND_SECURE_ZERO((b), sizeof(*(b)))
128128
#define mmc_buffer_reset(b) (b)->value.len = (b)->idx = 0
129129

130130
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L

php7/memcache_queue.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ MMC_QUEUE_INLINE void mmc_queue_free(mmc_queue_t *queue) {
9191
if (queue->items != NULL) {
9292
efree(queue->items);
9393
}
94-
memset(queue, 0, sizeof(*queue));
94+
ZEND_SECURE_ZERO(queue, sizeof(*queue));
9595
}
9696

9797
MMC_QUEUE_INLINE void mmc_queue_copy(mmc_queue_t *target, mmc_queue_t *source) {

php7/memcache_queue.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ typedef struct mmc_queue {
3333
int len;
3434
} mmc_queue_t;
3535

36-
#define mmc_queue_release(q) memset((q), 0, sizeof(*(q)))
36+
#define mmc_queue_release(q) ZEND_SECURE_ZERO((q), sizeof(*(q)))
3737
#define mmc_queue_reset(q) (q)->len = (q)->head = (q)->tail = 0
3838
#define mmc_queue_item(q, i) ((q)->tail + (i) < (q)->alloc ? (q)->items[(q)->tail + (i)] : (q)->items[(i) - ((q)->alloc - (q)->tail)])
3939

php7/memcache_standard_hash.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ typedef struct mmc_standard_state {
3838
void *mmc_standard_create_state(mmc_hash_function_t *hash) /* {{{ */
3939
{
4040
mmc_standard_state_t *state = emalloc(sizeof(mmc_standard_state_t));
41-
memset(state, 0, sizeof(mmc_standard_state_t));
41+
ZEND_SECURE_ZERO(state, sizeof(mmc_standard_state_t));
4242
state->hash = hash;
4343
return state;
4444
}

0 commit comments

Comments
 (0)