Commit 4fb91d9
committed
bugfix: shdict ffi store/incr silently truncated keys > 65535 bytes.
ngx_stream_lua_shdict_node_t::key_len is a u_short (uint16). The
ngx_stream_lua_ffi_shdict_store() and ngx_stream_lua_ffi_shdict_incr()
entry points accepted key_len as size_t and assigned it through a
(u_short) cast without bounds-checking, so a key longer than 65535
bytes was silently truncated when stored on the node, while the slab
allocation and the key memcpy still used the untruncated length.
The truncated sd->key_len was later used as an offset to locate the
value, landing inside the key bytes and reading the wrong data or
going past the value.
Mirror the > 65535 check already enforced by the Lua-stack API path
(see ngx_stream_lua_shdict_set_helper) at the FFI entry points so the
truncating cast is unreachable.
Mirrors the fix in lua-nginx-module.1 parent ae32ae6 commit 4fb91d9
1 file changed
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1244 | 1244 | | |
1245 | 1245 | | |
1246 | 1246 | | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
1247 | 1252 | | |
1248 | 1253 | | |
1249 | 1254 | | |
| |||
1651 | 1656 | | |
1652 | 1657 | | |
1653 | 1658 | | |
| 1659 | + | |
| 1660 | + | |
| 1661 | + | |
| 1662 | + | |
| 1663 | + | |
1654 | 1664 | | |
1655 | 1665 | | |
1656 | 1666 | | |
| |||
0 commit comments