]> git.kaiwu.me - njs.git/commit
Modules: fix out-of-bounds read when loading a shared dict file
authorDmitry Volyntsev <xeioex@nginx.com>
Thu, 11 Jun 2026 04:12:25 +0000 (21:12 -0700)
committerDmitry Volyntsev <xeioexception@gmail.com>
Thu, 11 Jun 2026 15:21:53 +0000 (08:21 -0700)
commitccb1365bb181d8bbbe9dce0afff574fad1ed082d
tree0bb13822bf400e3cedce4c3423cea9bc047deb7a
parent61380350678e5c4648afa0b82a65574d2abca248
Modules: fix out-of-bounds read when loading a shared dict file

Previously, ngx_js_dict_parse_entry() parsed numeric values with
strtod((char *) p, &p), which has no end awareness. The state
file loader allocated a buffer sized to the exact file length and
passed end = buf + len, so a numeric token whose digits ran to the
very end of the allocation (for example a truncated or tampered
state file ending in '"value":123') let strtod() read past the
buffer into adjacent pool memory.

NUL-terminate the loaded buffer so strtod() stops at the file end.
nginx/ngx_js_shared_dict.c