openresty / openresty/lua-resty-core

Don't blindly intern error strings

Open
#120 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Lua
Stars
853
Forks
286
Avg merge
35m
Merged PRs (30d)
1

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the shdict FFI call in src/ngx_http_lua_shdict.c around line 2639, then trace the Lua code that calls ffi_string(errmsg[0]). Reproduce the NULL-zone error path and determine whether the Lua or C side should guarantee a valid error message; done means stale or NULL errmsg values are no longer interned.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.