mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
parser: fix index out of bounds error (#4484)
+ revert 1bc9980 to use files in workspace
This commit is contained in:
+2
-2
@@ -11,10 +11,10 @@ cargo-fuzz = true
|
||||
libfuzzer-sys = "0.4"
|
||||
|
||||
[dependencies.uucore]
|
||||
uucore = { workspace = true }
|
||||
path = "../src/uucore/"
|
||||
|
||||
[dependencies.uu_date]
|
||||
uu_date = { workspace = true }
|
||||
path = "../src/uu/date/"
|
||||
|
||||
# Prevent this from interfering with workspaces
|
||||
[workspace]
|
||||
|
||||
@@ -10,8 +10,9 @@ fn fix_negation(glob: &str) -> String {
|
||||
let mut chars = glob.chars().collect::<Vec<_>>();
|
||||
|
||||
let mut i = 0;
|
||||
while i < chars.len() {
|
||||
if chars[i] == '[' && i + 4 <= glob.len() && chars[i + 1] == '^' {
|
||||
// Add 3 to prevent out of bounds in loop
|
||||
while i + 3 < chars.len() {
|
||||
if chars[i] == '[' && chars[i + 1] == '^' {
|
||||
match chars[i + 3..].iter().position(|x| *x == ']') {
|
||||
None => (),
|
||||
Some(j) => {
|
||||
@@ -105,5 +106,8 @@ mod tests {
|
||||
assert_eq!(fix_negation("[^]"), "[^]");
|
||||
assert_eq!(fix_negation("[^"), "[^");
|
||||
assert_eq!(fix_negation("[][^]"), "[][^]");
|
||||
|
||||
// Issue #4479
|
||||
assert_eq!(fix_negation("ààà[^"), "ààà[^");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user