Commit 524dc54
authored
fix(interpreter): cap glob_match calls in remove_pattern_glob (#1016)
## Summary
- Cap `glob_match` invocations in `remove_pattern_glob` to 10,000 to
prevent O(n^2) CPU exhaustion
- Bracket expressions like `[a]*` on long strings no longer cause
quadratic scanning
Closes #994
## Test plan
- [x] New spec tests: `glob_match_cap.test.sh` with 4 cases
- [x] `cargo test --all-features` passes
- [x] `cargo clippy -- -D warnings` clean1 parent 9bfe855 commit 524dc54
File tree
2 files changed
+48
-0
lines changed- crates/bashkit
- src/interpreter
- tests/spec_cases/bash
2 files changed
+48
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6921 | 6921 | | |
6922 | 6922 | | |
6923 | 6923 | | |
| 6924 | + | |
| 6925 | + | |
| 6926 | + | |
6924 | 6927 | | |
6925 | 6928 | | |
6926 | 6929 | | |
6927 | 6930 | | |
6928 | 6931 | | |
6929 | 6932 | | |
6930 | 6933 | | |
| 6934 | + | |
6931 | 6935 | | |
| 6936 | + | |
6932 | 6937 | | |
6933 | 6938 | | |
6934 | 6939 | | |
6935 | 6940 | | |
| 6941 | + | |
| 6942 | + | |
| 6943 | + | |
| 6944 | + | |
6936 | 6945 | | |
6937 | 6946 | | |
6938 | 6947 | | |
| |||
6948 | 6957 | | |
6949 | 6958 | | |
6950 | 6959 | | |
| 6960 | + | |
| 6961 | + | |
| 6962 | + | |
| 6963 | + | |
6951 | 6964 | | |
6952 | 6965 | | |
6953 | 6966 | | |
| |||
Lines changed: 35 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
0 commit comments