Skip to content

Commit 340da7f

Browse files
tugruldenji
authored andcommitted
empty key check
it coredumps when cache key is empty
1 parent e60093f commit 340da7f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

ngx_cache_purge_module.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -1832,7 +1832,9 @@ ngx_http_cache_purge_is_partial(ngx_http_request_t *r) {
18321832
key = c->keys.elts;
18331833

18341834
/* Only check the first key */
1835-
return key[0].data[key[0].len - 1] == '*';
1835+
return c->keys.nelts > 0 // number of array elements
1836+
&& key[0].len > 0 // char length of the key
1837+
&& key[0].data[key[0].len - 1] == '*'; // is the last char an asterix char?
18361838
}
18371839

18381840
char *

0 commit comments

Comments
 (0)