Skip to content

Commit

Permalink
fix(*) resolve a possible segfault in the FFI
Browse files Browse the repository at this point in the history
Creating the `rctx` can happen when no `wasm{}` block is configured
(e.g. through the FFI in `init_worker`). For example,
`set_host_properties_handlers()` might be called (wrong and unlikely,
but possible).

Always assume `rctx` might not be created due to a `wasm{}` block.
  • Loading branch information
thibaultcha committed Nov 28, 2023
1 parent caab792 commit 9c661a8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/http/ngx_http_wasm_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -584,11 +584,11 @@ ngx_http_wasm_rctx(ngx_http_request_t *r, ngx_http_wasm_req_ctx_t **out)
rctx->sock_buffer_reuse = loc->socket_buffer_reuse;
rctx->pwm_lua_resolver = loc->pwm_lua_resolver != NGX_CONF_UNSET
? loc->pwm_lua_resolver
: wcf->pwm_lua_resolver;
: wcf ? wcf->pwm_lua_resolver : 0;

} else {
/* fake request */
rctx->pwm_lua_resolver = wcf->pwm_lua_resolver;
rctx->pwm_lua_resolver = wcf ? wcf->pwm_lua_resolver : 0;
}
}
#if (NGX_DEBUG)
Expand Down
4 changes: 3 additions & 1 deletion src/wasm/ngx_wasm_core_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,9 @@ ngx_wasm_core_ssl_conf(ngx_cycle_t *cycle)
ngx_wasm_core_conf_t *wcf;

wcf = ngx_wasm_core_cycle_get_conf(cycle);
ngx_wasm_assert(wcf);
if (wcf == NULL) {
return NULL;
}

return &wcf->ssl_conf;
}
Expand Down

0 comments on commit 9c661a8

Please sign in to comment.