Skip to content

Commit 6a05d73

Browse files
committed
handler validation check
1 parent b67632c commit 6a05d73

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

src/ngx_http_c_func_module.c

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -970,9 +970,14 @@ ngx_http_c_func_after_process(ngx_event_t *ev) {
970970
static ngx_int_t
971971
ngx_http_c_func_precontent_handler(ngx_http_request_t *r) {
972972
// ngx_str_t name;
973-
ngx_http_c_func_loc_conf_t *lcf = ngx_http_get_module_loc_conf(r, ngx_http_c_func_module);
974-
ngx_http_c_func_main_conf_t *mcf = ngx_http_get_module_main_conf(r, ngx_http_c_func_module);
975-
ngx_http_c_func_internal_ctx_t *internal_ctx;
973+
ngx_http_c_func_loc_conf_t *lcf = ngx_http_get_module_loc_conf(r, ngx_http_c_func_module);
974+
ngx_http_c_func_main_conf_t *mcf = ngx_http_get_module_main_conf(r, ngx_http_c_func_module);
975+
ngx_http_c_func_internal_ctx_t *internal_ctx;
976+
ngx_http_c_func_ctx_t *new_ctx;
977+
978+
if (lcf->_handler == NULL) {
979+
return NGX_DECLINED;
980+
}
976981

977982
internal_ctx = ngx_http_get_module_ctx(r, ngx_http_c_func_module);
978983

@@ -998,12 +1003,7 @@ ngx_http_c_func_precontent_handler(ngx_http_request_t *r) {
9981003
}
9991004

10001005
new_task:
1001-
if (lcf->_handler == NULL) {
1002-
return NGX_DECLINED;
1003-
}
1004-
1005-
1006-
ngx_http_c_func_ctx_t *new_ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_c_func_ctx_t));
1006+
new_ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_c_func_ctx_t));
10071007
new_ctx->__r__ = r;
10081008
new_ctx->__pl__ = r->pool;
10091009
new_ctx->__log__ = r->connection->log;
@@ -1157,10 +1157,14 @@ ngx_http_c_func_precontent_handler(ngx_http_request_t *r) {
11571157
*/
11581158
static ngx_int_t
11591159
ngx_http_c_func_rewrite_handler(ngx_http_request_t *r) {
1160-
// ngx_http_c_func_loc_conf_t *lcf = ngx_http_get_module_loc_conf(r, ngx_http_c_func_module);
1160+
ngx_http_c_func_loc_conf_t *lcf = ngx_http_get_module_loc_conf(r, ngx_http_c_func_module);
11611161
ngx_http_c_func_internal_ctx_t *ctx;
11621162
ngx_int_t rc;
11631163

1164+
if (lcf->_handler == NULL) {
1165+
return NGX_DECLINED;
1166+
}
1167+
11641168
if (r->method & (NGX_HTTP_POST | NGX_HTTP_PUT | NGX_HTTP_PATCH)) {
11651169
// r->request_body_in_single_buf = 1;
11661170
// r->request_body_in_clean_file = 1;
@@ -1220,8 +1224,7 @@ ngx_http_c_func_rewrite_handler(ngx_http_request_t *r) {
12201224
}
12211225

12221226
static void
1223-
ngx_http_c_func_client_body_handler(ngx_http_request_t *r)
1224-
{
1227+
ngx_http_c_func_client_body_handler(ngx_http_request_t *r) {
12251228
ngx_http_c_func_internal_ctx_t *ctx;
12261229
ctx = ngx_http_get_module_ctx(r, ngx_http_c_func_module);
12271230
ctx->done = 1;

0 commit comments

Comments
 (0)