grep - interval counts above 32767 are accepted; GNU rejects them with `Regular expression too big`
维护者通常 2 天内回复
评估
调研方向
首先追踪 uu_grep 如何解析 BRE 和 ERE 区间计数并将其传递给 Oniguruma;issue 指出 ONIG_MAX_REPEAT_NUM 是不一致的根源。为大于 32767 的计数和可接受的边界值添加覆盖,并参考复现案例和 GNU grep 的 bre 测试。完成标准是:超大边界值以退出码 2 和“Regular expression too big”报错,而 32767 仍被接受。
由索引模型根据 Issue 内容生成。
描述
GNU grep accepts interval counts up to 32767 and rejects anything larger, in BRE and ERE and
for either bound, with Regular expression too big and exit 2 (observed with GNU grep 3.12:
k{32767} compiles, k{32768} does not). uu_grep passes the interval to Oniguruma, whose
own limit is 100000 (ONIG_MAX_REPEAT_NUM), so k{40000} and k{1,40000} are searched
and exit 0/1.
Exposed by the GNU test bre (Spencer BRE test #44, a\{32768\} must exit 2).
Reproduction
Rust (incorrect)
$ printf 'kk\n' | ./target/release/grep -E 'k{40000}'
# Output: (none)
# Exit code: 1
$ printf 'kk\n' | ./target/release/grep 'k\{40000\}'
# Output: (none)
# Exit code: 1
$ printf 'kk\n' | ./target/release/grep -E 'k{1,40000}'
kk
# Exit code: 0
GNU (correct)
$ printf 'kk\n' | LC_ALL=C /usr/bin/grep -E 'k{40000}'
/usr/bin/grep: Regular expression too big
# Exit code: 2
$ printf 'kk\n' | LC_ALL=C /usr/bin/grep 'k\{40000\}'
/usr/bin/grep: Regular expression too big
# Exit code: 2
$ printf 'kk\n' | LC_ALL=C /usr/bin/grep -E 'k{1,40000}'
/usr/bin/grep: Regular expression too big
# Exit code: 2
Test
#[test]
fn interval_count_limit() {
for args in [
&["-E", "w{32800}"][..],
&["w\\{2,50000\\}"][..],
&["-E", "w{,32768}"][..],
] {
let (_s, mut c) = ucmd();
c.args(args)
.pipe_in("ww\n")
.fails_with_code(2)
.no_stdout()
.stderr_contains("Regular expression too big");
}
// The largest accepted count still works.
let (_s, mut c) = ucmd();
c.args(&["-E", "-c", "w{32767}"])
.pipe_in("ww\n")
.fails_with_code(1)
.stdout_only("0\n");
}
Exposed by the GNU grep test suite: bre.
- 主要语言
- Rust
- 星标
- 147
- 派生
- 34
- 平均合并
- 3 天 18 小时
- 30 天内合并 PR
- 21
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
uutils/grep 的其他 Issue
-
grep - `-L` with `-m 0` or `-v ''` prints nothing; GNU still lists every file可能已有人在做 @yunusarda-sudo 于 5 天前认领。 未关闭bug gnu-compat good first issue
难度 2/5 1-3 小时 新手友好度 83/100
维护者通常 2 天内回复
-
grep - `-v -o` with `-A`/`-B`/`-C` prints nothing; GNU prints the matches found in the context lines未关闭bug gnu-compat good first issue
难度 2/5 1-3 小时 新手友好度 83/100
维护者通常 2 天内回复
-
grep - `--exclude-dir=./dir` does not exclude the operand `./dir`可能已有人在做 @yunusarda-sudo 于 5 天前认领。 未关闭bug gnu-compat good first issue
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 2 天内回复
-
bug gnu-compat good first issue
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 2 天内回复
-
gnu-compat good first issue oss-scanner
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 2 天内回复
相似的 Issue
-
marketing
难度 2/5 半天 新手友好度 62/100
维护者通常 1 天内回复
-
S: Untriaged T: Bug
难度 2/5 1-3 小时 新手友好度 72/100
libnyanpasu/clash-nyanpasu#6537 ·
维护者通常 1 天内回复
-
难度 2/5 1 小时以内 新手友好度 62/100
tauri-apps/tao#1445 ·
维护者通常 1 天内回复
-
bug P3
难度 1/5 1-3 小时 新手友好度 88/100
-
go good first issue test
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 2 天内回复