lua-resty-core icon indicating copy to clipboard operation
lua-resty-core copied to clipboard

Don't blindly intern error strings

Open javierguerragiraldez opened this issue 7 years ago • 1 comments

Some low level functions don't set the errmsg pointer on every possible error. Case in point, if the shdict FFI functions are called with a NULL zone, they just return NGX_ERROR, and the Lua part calls ffi_string(errmsg[0]) with an stale message, or even a NULL value. (https://github.com/openresty/lua-nginx-module/blob/master/src/ngx_http_lua_shdict.c#L2639)

This could be fixed either in Lua with more paranoid style (and acknowledge that the errmsg "might be setup or not") or on the C side making sure that the errmsg is always set before returning.

javierguerragiraldez avatar Jun 19 '17 08:06 javierguerragiraldez

@javierguerragiraldez I think we should just set the error message properly on the C land right before returning NGX_ERROR. A default error message is not really helpful. Will you please contribute a patch for the missing *err = "no zone found" assignment at https://github.com/openresty/lua-nginx-module/blob/master/src/ngx_http_lua_shdict.c#L2639 ? Many thanks!

agentzh avatar Jun 19 '17 16:06 agentzh