Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
optimize: switched exptime argument type to 'long' in the shdict FFI …
…API to avoid potential overflows.
  • Loading branch information
thibaultcha committed Jan 24, 2018
commit ddb40d4097be96348d81306b41e18515fbfd016c
8 changes: 4 additions & 4 deletions src/ngx_http_lua_shdict.c
Original file line number Diff line number Diff line change
Expand Up @@ -2212,7 +2212,7 @@ ngx_http_lua_find_zone(u_char *name_data, size_t name_len)
int
ngx_http_lua_ffi_shdict_store(ngx_shm_zone_t *zone, int op, u_char *key,
size_t key_len, int value_type, u_char *str_value_buf,
size_t str_value_len, double num_value, int exptime, int user_flags,
size_t str_value_len, double num_value, long exptime, int user_flags,
char **errmsg, int *forcible)
{
int i, n;
Expand All @@ -2229,7 +2229,7 @@ ngx_http_lua_ffi_shdict_store(ngx_shm_zone_t *zone, int op, u_char *key,
return NGX_ERROR;
}

dd("exptime: %d", exptime);
dd("exptime: %ld", exptime);

ctx = zone->data;

Expand Down Expand Up @@ -2903,7 +2903,7 @@ ngx_http_lua_shdict_peek(ngx_shm_zone_t *shm_zone, ngx_uint_t hash,
}


int
long
ngx_http_lua_ffi_shdict_get_ttl(ngx_shm_zone_t *zone, u_char *key,
size_t key_len)
{
Expand Down Expand Up @@ -2951,7 +2951,7 @@ ngx_http_lua_ffi_shdict_get_ttl(ngx_shm_zone_t *zone, u_char *key,

int
ngx_http_lua_ffi_shdict_set_expire(ngx_shm_zone_t *zone, u_char *key,
size_t key_len, int exptime)
size_t key_len, long exptime)
{
uint32_t hash;
ngx_int_t rc;
Expand Down