oxc/crates
overlookmotel 62bc8c5cea
fix(parser): error on source larger than 4 GiB (#1860)
`Token` and `Span` both represent `start` and `end` as `u32`.

This limits size of source which can be parsed to `u32::MAX`.


19577709db/crates/oxc_span/src/span.rs (L14-L20)

However, this constraint is currently not enforced.

In a release build, code will not panic on arithmetic overflow, so
`start`/`end` could wrap around back to zero if source is 4 GiB or more.

That'd produce nonsense spans. But worse, the lexer relies in some
places on `self.current.token.start` being correct, so if the value
wrapped around, possibly it'd keep rewinding to the start of the source
and lexing it again, causing an infinite loop.

In worst case, if for some reason an application's public API used OXC's
parser with user-supplied source code (parser-as-a-service!), this could
be exploited for denial of service.

This PR adds an assertion to catch this at the start of parsing instead.

This does add an extra instruction, but I imagine the effect will be
negligible compared to the work required to parse the code.
2024-01-02 11:05:28 +08:00
..
oxc Release crates v0.4.0 2023-12-08 17:20:37 +08:00
oxc_allocator Release crates v0.4.0 2023-12-08 17:20:37 +08:00
oxc_ast fix(ast): implement GetSpan for JSXElement (#1861) 2023-12-31 22:08:11 +08:00
oxc_cli test(cli): add simple integration test for vue file (#1863) 2023-12-31 22:37:26 +08:00
oxc_codegen Release crates v0.4.0 2023-12-08 17:20:37 +08:00
oxc_diagnostics chore(deps): bump the dependencies group with 11 updates (#1865) 2024-01-01 08:06:33 +00:00
oxc_formatter Release crates v0.4.0 2023-12-08 17:20:37 +08:00
oxc_index Release crates v0.4.0 2023-12-08 17:20:37 +08:00
oxc_js_regex Initialize JS Regex crates and def AST. (#1500) 2023-11-23 00:22:17 +08:00
oxc_language_server feat(vscode): support lint vue file (#1842) 2023-12-31 22:31:26 +08:00
oxc_linter feat(linter): eslint-plugin-jsx-a11y mouse-events-have-key-events (correctness) (#1867) 2024-01-01 11:26:49 +00:00
oxc_linter_plugin chore(deps): bump the dependencies group with 5 updates (#1808) 2023-12-25 15:17:47 +08:00
oxc_macros feat(linter): add a perf category (#1625) 2023-12-04 17:31:34 +08:00
oxc_minifier chore: upgrade rustc toolchain to stable 1.75.0 (#1853) 2023-12-29 12:20:51 +08:00
oxc_parser fix(parser): error on source larger than 4 GiB (#1860) 2024-01-02 11:05:28 +08:00
oxc_prettier feat(linter): no-irregular-whitespace rule (#1835) 2023-12-31 12:05:38 +08:00
oxc_query feat(query): Add is_getter, is_setter, is_constructor to all Function implementors (#1526) 2023-11-27 12:22:41 +08:00
oxc_semantic refactor(semantic): improve check function declaration implementation (#1854) 2023-12-31 22:17:56 +08:00
oxc_span Release crates v0.4.0 2023-12-08 17:20:37 +08:00
oxc_syntax feat(semantic): improve check super implementation, reduce access nodes (#1827) 2023-12-27 22:36:28 +08:00
oxc_transformer chore: upgrade rustc toolchain to stable 1.75.0 (#1853) 2023-12-29 12:20:51 +08:00
oxc_type_synthesis
oxc_wasm feat(linter): add jsx-a11y settings (#1668) 2023-12-16 13:45:14 +08:00