lua-resty-core
lua-resty-core copied to clipboard
Don't blindly intern error strings
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 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!