openresty / openresty/lua-nginx-module
`ngx.re` allocate too small space for pcre workspace
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 11.8k
- Forks
- 2.1k
- Avg merge
- 6h 1m
- Merged PRs (30d)
- 6
Description
When I test with DFA mode regex match with case:
^(?i:(?:[a-z]{3,10}\s+(?:\w{3,7}?://[\w\-\./]*(?::\d+)?)?/[^?#]*(?:\?[^#\s]*)?(?:#[\S]*)?|connect (?:\d{1,3}\.){3}\d{1,3}\.?(?::\d+)?|options \*)\s+[\w\./]+|get /[^?#]*(?:\?[^#\s]*)?(?:#[\S]*)?)$
which simply verify format of request line,
and given input:
GET / HTTP/1.1
it gives out an error number of -19.
with a little bit of effort I found out that -19( PCRE_ERROR_DFA_WSSIZE) means pcre requiring more space for workspace, and ngx_lua module define NGX_LUA_RE_DFA_MODE_WORKSPACE_COUNT as 100.
as reference, pcre_dfa_exec defines local_workspace as 1000 of ints. that maybe sufficient.
how is NGX_LUA_RE_DFA_MODE_WORKSPACE_COUNT decided and is it possible to use larger workspace?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing NGX_LUA_RE_DFA_MODE_WORKSPACE_COUNT through the ngx_lua regex implementation and compare it with pcre_dfa_exec's local_workspace size. Reproduce the DFA case with the supplied pattern and request line, then verify that the workspace no longer returns PCRE_ERROR_DFA_WSSIZE (-19).
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100