Skip to content

Commit ddb40d4

Browse files
committed
optimize: switched exptime argument type to 'long' in the shdict FFI API to
avoid potential overflows.
1 parent df1b019 commit ddb40d4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/ngx_http_lua_shdict.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2212,7 +2212,7 @@ ngx_http_lua_find_zone(u_char *name_data, size_t name_len)
22122212
int
22132213
ngx_http_lua_ffi_shdict_store(ngx_shm_zone_t *zone, int op, u_char *key,
22142214
size_t key_len, int value_type, u_char *str_value_buf,
2215-
size_t str_value_len, double num_value, int exptime, int user_flags,
2215+
size_t str_value_len, double num_value, long exptime, int user_flags,
22162216
char **errmsg, int *forcible)
22172217
{
22182218
int i, n;
@@ -2229,7 +2229,7 @@ ngx_http_lua_ffi_shdict_store(ngx_shm_zone_t *zone, int op, u_char *key,
22292229
return NGX_ERROR;
22302230
}
22312231

2232-
dd("exptime: %d", exptime);
2232+
dd("exptime: %ld", exptime);
22332233

22342234
ctx = zone->data;
22352235

@@ -2903,7 +2903,7 @@ ngx_http_lua_shdict_peek(ngx_shm_zone_t *shm_zone, ngx_uint_t hash,
29032903
}
29042904

29052905

2906-
int
2906+
long
29072907
ngx_http_lua_ffi_shdict_get_ttl(ngx_shm_zone_t *zone, u_char *key,
29082908
size_t key_len)
29092909
{
@@ -2951,7 +2951,7 @@ ngx_http_lua_ffi_shdict_get_ttl(ngx_shm_zone_t *zone, u_char *key,
29512951

29522952
int
29532953
ngx_http_lua_ffi_shdict_set_expire(ngx_shm_zone_t *zone, u_char *key,
2954-
size_t key_len, int exptime)
2954+
size_t key_len, long exptime)
29552955
{
29562956
uint32_t hash;
29572957
ngx_int_t rc;

0 commit comments

Comments
 (0)