css_parse: Ensure buffer is refilled if skipping past a whole buffer - #1180
Merged
keithamus merged 1 commit intoJun 5, 2026
Merged
Conversation
It's possible to cause a panic in csskit by filling the buffer with skip tokens, such as comments: 11 comment tokens in a row will cause the next icon to reach the end of the buffer, and cause an index OOB panic. This occurs because `next()` unconditionally calls `buffer_index = i + 1` for skip tokens, so when the buffer landed at slot 11, `buffer_index` becomes 12 (OOB). This change ensures the buffer is refilled, even when skipping tokens, by refactoring to add an outer loop and ensuring skip tokens don't advance the buffer in the inner loop. `fill_buffer` gets called at the end of the outer loop to ensure it is not exhausted.
keithamus
enabled auto-merge (squash)
June 5, 2026 17:43
keithamus
deleted the
css-parse-ensure-buffer-is-refilled-if-skipping-past-a-whole-buffer
branch
June 5, 2026 17:51
Merged
github-actions Bot
pushed a commit
that referenced
this pull request
Jun 5, 2026
## [0.0.25] - 2026-06-05
### Css_ast
- css_ast: Avoid hanging on `={-->}` input. (#1183) ([#1183](#1183))
### Css_parse
- css_parse: Ensure buffer is refilled if skipping past a whole buffer (#1180) ([#1180](#1180))
### Csskit
- csskit: improve json output for subcommands (#1182) ([#1182](#1182))
[forcebuild]
github-actions Bot
pushed a commit
that referenced
this pull request
Jun 8, 2026
## [0.0.25] - 2026-06-08 ### Other Changes - Update cargo deps (#1189) ([#1189](#1189)) - Push allocator-api2 back to 2.21 due to bumpalo (#1191) ([#1191](#1191)) ### Css_ast - css_ast: Avoid hanging on `={-->}` input. (#1183) ([#1183](#1183)) ### Css_parse - css_parse: Ensure buffer is refilled if skipping past a whole buffer (#1180) ([#1180](#1180)) ### Csskit - csskit: improve json output for subcommands (#1182) ([#1182](#1182)) - chore(deps): update dependencies (patch) (#1185) ([#1185](#1185)) [forcebuild]
github-actions Bot
pushed a commit
that referenced
this pull request
Jun 8, 2026
## [0.0.25] - 2026-06-08 ### Other Changes - Update cargo deps (#1189) ([#1189](#1189)) - Push allocator-api2 back to 2.21 due to bumpalo (#1191) ([#1191](#1191)) ### Css_ast - css_ast: Avoid hanging on `={-->}` input. (#1183) ([#1183](#1183)) ### Css_parse - css_parse: Ensure buffer is refilled if skipping past a whole buffer (#1180) ([#1180](#1180)) ### Csskit - csskit: improve json output for subcommands (#1182) ([#1182](#1182)) - chore(deps): update dependencies (patch) (#1185) ([#1185](#1185))
github-actions Bot
pushed a commit
that referenced
this pull request
Jun 8, 2026
## [0.0.25] - 2026-06-08 ### Other Changes - Update cargo deps (#1189) ([#1189](#1189)) - Push allocator-api2 back to 2.21 due to bumpalo (#1191) ([#1191](#1191)) ### Css_ast - css_ast: Avoid hanging on `={-->}` input. (#1183) ([#1183](#1183)) - Regenerate css_ast/src/values from csswg drafts (#1184) ([#1184](#1184)) ### Css_parse - css_parse: Ensure buffer is refilled if skipping past a whole buffer (#1180) ([#1180](#1180)) - css_parse: Impl ToSpan for Comparison (#1190) ([#1190](#1190)) ### Csskit - csskit: improve json output for subcommands (#1182) ([#1182](#1182)) - chore(deps): update dependencies (patch) (#1185) ([#1185](#1185)) ### Csskit_vscode - chore(deps): update dependency @vscode/test-electron to v3 (#1192) ([#1192](#1192)) [forcebuild]
github-actions Bot
pushed a commit
that referenced
this pull request
Jun 8, 2026
## [0.0.25] - 2026-06-08 ### Other Changes - Update cargo deps (#1189) ([#1189](#1189)) - Push allocator-api2 back to 2.21 due to bumpalo (#1191) ([#1191](#1191)) ### Css_ast - css_ast: Avoid hanging on `={-->}` input. (#1183) ([#1183](#1183)) - Regenerate css_ast/src/values from csswg drafts (#1184) ([#1184](#1184)) ### Css_parse - css_parse: Ensure buffer is refilled if skipping past a whole buffer (#1180) ([#1180](#1180)) - css_parse: Impl ToSpan for Comparison (#1190) ([#1190](#1190)) ### Csskit - csskit: improve json output for subcommands (#1182) ([#1182](#1182)) - chore(deps): update dependencies (patch) (#1185) ([#1185](#1185)) ### Csskit_vscode - chore(deps): update dependency @vscode/test-electron to v3 (#1192) ([#1192](#1192))
github-actions Bot
pushed a commit
that referenced
this pull request
Jun 10, 2026
## [0.0.25] - 2026-06-10 ### Other Changes - Update cargo deps (#1189) ([#1189](#1189)) - Push allocator-api2 back to 2.21 due to bumpalo (#1191) ([#1191](#1191)) ### Css_ast - css_ast: Avoid hanging on `={-->}` input. (#1183) ([#1183](#1183)) - Regenerate css_ast/src/values from csswg drafts (#1184) ([#1184](#1184)) - css_ast: Use assert_parse! closure macro variant in tests. (#1196) ([#1196](#1196)) ### Css_parse - css_parse: Ensure buffer is refilled if skipping past a whole buffer (#1180) ([#1180](#1180)) - css_parse: Impl ToSpan for Comparison (#1190) ([#1190](#1190)) - Impl Display for Comparison (#1193) ([#1193](#1193)) - css_parse: Improve assert_parse! macros to use a block/closure (#1194) ([#1194](#1194)) ### Csskit - csskit: improve json output for subcommands (#1182) ([#1182](#1182)) - chore(deps): update dependencies (patch) (#1185) ([#1185](#1185)) ### Csskit_vscode - chore(deps): update dependency @vscode/test-electron to v3 (#1192) ([#1192](#1192)) [forcebuild]
github-actions Bot
pushed a commit
that referenced
this pull request
Jun 10, 2026
## [0.0.25] - 2026-06-10 ### Other Changes - Update cargo deps (#1189) ([#1189](#1189)) - Push allocator-api2 back to 2.21 due to bumpalo (#1191) ([#1191](#1191)) ### Css_ast - css_ast: Avoid hanging on `={-->}` input. (#1183) ([#1183](#1183)) - Regenerate css_ast/src/values from csswg drafts (#1184) ([#1184](#1184)) - css_ast: Use assert_parse! closure macro variant in tests. (#1196) ([#1196](#1196)) ### Css_parse - css_parse: Ensure buffer is refilled if skipping past a whole buffer (#1180) ([#1180](#1180)) - css_parse: Impl ToSpan for Comparison (#1190) ([#1190](#1190)) - Impl Display for Comparison (#1193) ([#1193](#1193)) - css_parse: Improve assert_parse! macros to use a block/closure (#1194) ([#1194](#1194)) ### Csskit - csskit: improve json output for subcommands (#1182) ([#1182](#1182)) - chore(deps): update dependencies (patch) (#1185) ([#1185](#1185)) ### Csskit_vscode - chore(deps): update dependency @vscode/test-electron to v3 (#1192) ([#1192](#1192))
github-actions Bot
pushed a commit
that referenced
this pull request
Jun 12, 2026
## [0.0.25] - 2026-06-12 ### Other Changes - Update cargo deps (#1189) ([#1189](#1189)) - Push allocator-api2 back to 2.21 due to bumpalo (#1191) ([#1191](#1191)) - Fuzz: Try setting up a fuzzing suite (#1201) ([#1201](#1201)) ### Css_ast - css_ast: Avoid hanging on `={-->}` input. (#1183) ([#1183](#1183)) - Regenerate css_ast/src/values from csswg drafts (#1184) ([#1184](#1184)) - css_ast: Use assert_parse! closure macro variant in tests. (#1196) ([#1196](#1196)) - cssast/csskit_derives: Add new FeatureMetadata system (#1197) ([#1197](#1197)) - csskit_derives/css_ast: make derive(IntoCursor) work with generics (#1200) ([#1200](#1200)) - css_ast: Implement a NonEmpty generic (#1202) ([#1202](#1202)) ### Css_parse - css_parse: Ensure buffer is refilled if skipping past a whole buffer (#1180) ([#1180](#1180)) - css_parse: Impl ToSpan for Comparison (#1190) ([#1190](#1190)) - Impl Display for Comparison (#1193) ([#1193](#1193)) - css_parse: Improve assert_parse! macros to use a block/closure (#1194) ([#1194](#1194)) ### Csskit - csskit: improve json output for subcommands (#1182) ([#1182](#1182)) - chore(deps): update dependencies (patch) (#1185) ([#1185](#1185)) ### Csskit_derives - csskit_derives: Ensure generics expect Peek when using it. (#1198) ([#1198](#1198)) ### Csskit_source_finder - csskit_source_finder: Don't find visitable nodes that just visit children (#1199) ([#1199](#1199)) ### Csskit_vscode - chore(deps): update dependency @vscode/test-electron to v3 (#1192) ([#1192](#1192)) [forcebuild]
github-actions Bot
pushed a commit
that referenced
this pull request
Jun 12, 2026
## [0.0.25] - 2026-06-12 ### Other Changes - Update cargo deps (#1189) ([#1189](#1189)) - Push allocator-api2 back to 2.21 due to bumpalo (#1191) ([#1191](#1191)) - Fuzz: Try setting up a fuzzing suite (#1201) ([#1201](#1201)) ### Css_ast - css_ast: Avoid hanging on `={-->}` input. (#1183) ([#1183](#1183)) - Regenerate css_ast/src/values from csswg drafts (#1184) ([#1184](#1184)) - css_ast: Use assert_parse! closure macro variant in tests. (#1196) ([#1196](#1196)) - cssast/csskit_derives: Add new FeatureMetadata system (#1197) ([#1197](#1197)) - csskit_derives/css_ast: make derive(IntoCursor) work with generics (#1200) ([#1200](#1200)) - css_ast: Implement a NonEmpty generic (#1202) ([#1202](#1202)) ### Css_parse - css_parse: Ensure buffer is refilled if skipping past a whole buffer (#1180) ([#1180](#1180)) - css_parse: Impl ToSpan for Comparison (#1190) ([#1190](#1190)) - Impl Display for Comparison (#1193) ([#1193](#1193)) - css_parse: Improve assert_parse! macros to use a block/closure (#1194) ([#1194](#1194)) ### Csskit - csskit: improve json output for subcommands (#1182) ([#1182](#1182)) - chore(deps): update dependencies (patch) (#1185) ([#1185](#1185)) ### Csskit_derives - csskit_derives: Ensure generics expect Peek when using it. (#1198) ([#1198](#1198)) ### Csskit_source_finder - csskit_source_finder: Don't find visitable nodes that just visit children (#1199) ([#1199](#1199)) ### Csskit_vscode - chore(deps): update dependency @vscode/test-electron to v3 (#1192) ([#1192](#1192))
github-actions Bot
pushed a commit
that referenced
this pull request
Jun 13, 2026
## [0.0.25] - 2026-06-13 ### Other Changes - Update cargo deps (#1189) ([#1189](#1189)) - Push allocator-api2 back to 2.21 due to bumpalo (#1191) ([#1191](#1191)) - Fuzz: Try setting up a fuzzing suite (#1201) ([#1201](#1201)) ### Css_ast - css_ast: Avoid hanging on `={-->}` input. (#1183) ([#1183](#1183)) - Regenerate css_ast/src/values from csswg drafts (#1184) ([#1184](#1184)) - css_ast: Use assert_parse! closure macro variant in tests. (#1196) ([#1196](#1196)) - cssast/csskit_derives: Add new FeatureMetadata system (#1197) ([#1197](#1197)) - csskit_derives/css_ast: make derive(IntoCursor) work with generics (#1200) ([#1200](#1200)) - css_ast: Implement a NonEmpty generic (#1202) ([#1202](#1202)) ### Css_lexer - fuzz: early return atom functions when given non-atom tokens (#1206) ([#1206](#1206)) - fuzz(css_lexer): ensure REPLACEMENT_CHARACTER is appended in small idents (#1213) ([#1213](#1213)) ### Css_parse - css_parse: Ensure buffer is refilled if skipping past a whole buffer (#1180) ([#1180](#1180)) - css_parse: Impl ToSpan for Comparison (#1190) ([#1190](#1190)) - Impl Display for Comparison (#1193) ([#1193](#1193)) - css_parse: Improve assert_parse! macros to use a block/closure (#1194) ([#1194](#1194)) ### Csskit - csskit: improve json output for subcommands (#1182) ([#1182](#1182)) - chore(deps): update dependencies (patch) (#1185) ([#1185](#1185)) ### Csskit_derives - csskit_derives: Ensure generics expect Peek when using it. (#1198) ([#1198](#1198)) ### Csskit_source_finder - csskit_source_finder: Don't find visitable nodes that just visit children (#1199) ([#1199](#1199)) ### Csskit_vscode - chore(deps): update dependency @vscode/test-electron to v3 (#1192) ([#1192](#1192)) - fix(deps): update dependency esbuild to v0.28.1 [security] (#1210) ([#1210](#1210)) [forcebuild]
github-actions Bot
pushed a commit
that referenced
this pull request
Jun 13, 2026
## [0.0.25] - 2026-06-13 ### Other Changes - Update cargo deps (#1189) ([#1189](#1189)) - Push allocator-api2 back to 2.21 due to bumpalo (#1191) ([#1191](#1191)) - Fuzz: Try setting up a fuzzing suite (#1201) ([#1201](#1201)) ### Css_ast - css_ast: Avoid hanging on `={-->}` input. (#1183) ([#1183](#1183)) - Regenerate css_ast/src/values from csswg drafts (#1184) ([#1184](#1184)) - css_ast: Use assert_parse! closure macro variant in tests. (#1196) ([#1196](#1196)) - cssast/csskit_derives: Add new FeatureMetadata system (#1197) ([#1197](#1197)) - csskit_derives/css_ast: make derive(IntoCursor) work with generics (#1200) ([#1200](#1200)) - css_ast: Implement a NonEmpty generic (#1202) ([#1202](#1202)) ### Css_lexer - fuzz: early return atom functions when given non-atom tokens (#1206) ([#1206](#1206)) - fuzz(css_lexer): ensure REPLACEMENT_CHARACTER is appended in small idents (#1213) ([#1213](#1213)) ### Css_parse - css_parse: Ensure buffer is refilled if skipping past a whole buffer (#1180) ([#1180](#1180)) - css_parse: Impl ToSpan for Comparison (#1190) ([#1190](#1190)) - Impl Display for Comparison (#1193) ([#1193](#1193)) - css_parse: Improve assert_parse! macros to use a block/closure (#1194) ([#1194](#1194)) ### Csskit - csskit: improve json output for subcommands (#1182) ([#1182](#1182)) - chore(deps): update dependencies (patch) (#1185) ([#1185](#1185)) ### Csskit_derives - csskit_derives: Ensure generics expect Peek when using it. (#1198) ([#1198](#1198)) ### Csskit_source_finder - csskit_source_finder: Don't find visitable nodes that just visit children (#1199) ([#1199](#1199)) ### Csskit_vscode - chore(deps): update dependency @vscode/test-electron to v3 (#1192) ([#1192](#1192)) - fix(deps): update dependency esbuild to v0.28.1 [security] (#1210) ([#1210](#1210))
keithamus
added a commit
that referenced
this pull request
Jun 13, 2026
## [0.0.25] - 2026-06-13 ### Other Changes - Update cargo deps (#1189) ([#1189](#1189)) - Push allocator-api2 back to 2.21 due to bumpalo (#1191) ([#1191](#1191)) - Fuzz: Try setting up a fuzzing suite (#1201) ([#1201](#1201)) ### Css_ast - css_ast: Avoid hanging on `={-->}` input. (#1183) ([#1183](#1183)) - Regenerate css_ast/src/values from csswg drafts (#1184) ([#1184](#1184)) - css_ast: Use assert_parse! closure macro variant in tests. (#1196) ([#1196](#1196)) - cssast/csskit_derives: Add new FeatureMetadata system (#1197) ([#1197](#1197)) - csskit_derives/css_ast: make derive(IntoCursor) work with generics (#1200) ([#1200](#1200)) - css_ast: Implement a NonEmpty generic (#1202) ([#1202](#1202)) ### Css_lexer - fuzz: early return atom functions when given non-atom tokens (#1206) ([#1206](#1206)) - fuzz(css_lexer): ensure REPLACEMENT_CHARACTER is appended in small idents (#1213) ([#1213](#1213)) ### Css_parse - css_parse: Ensure buffer is refilled if skipping past a whole buffer (#1180) ([#1180](#1180)) - css_parse: Impl ToSpan for Comparison (#1190) ([#1190](#1190)) - Impl Display for Comparison (#1193) ([#1193](#1193)) - css_parse: Improve assert_parse! macros to use a block/closure (#1194) ([#1194](#1194)) ### Csskit - csskit: improve json output for subcommands (#1182) ([#1182](#1182)) - chore(deps): update dependencies (patch) (#1185) ([#1185](#1185)) ### Csskit_derives - csskit_derives: Ensure generics expect Peek when using it. (#1198) ([#1198](#1198)) ### Csskit_source_finder - csskit_source_finder: Don't find visitable nodes that just visit children (#1199) ([#1199](#1199)) ### Csskit_vscode - chore(deps): update dependency @vscode/test-electron to v3 (#1192) ([#1192](#1192)) - fix(deps): update dependency esbuild to v0.28.1 [security] (#1210) ([#1210](#1210))
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
It's possible to cause a panic in csskit by filling the buffer with skip tokens,
such as comments: 11 comment tokens in a row will cause the next icon to reach
the end of the buffer, and cause an index OOB panic. This occurs because
next()unconditionally callsbuffer_index = i + 1for skip tokens, so whenthe buffer landed at slot 11,
buffer_indexbecomes 12 (OOB).This change ensures the buffer is refilled, even when skipping tokens, by
refactoring to add an outer loop and ensuring skip tokens don't advance the
buffer in the inner loop.
fill_buffergets called at the end of the outer loopto ensure it is not exhausted.