| Summary: | Awk segfault if NF is negative | ||
|---|---|---|---|
| Product: | Busybox | Reporter: | Luiz Angelo Daros de Luca <luizluca> |
| Component: | Other | Assignee: | unassigned |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | busybox-cvs |
| Priority: | P5 | ||
| Version: | 1.28.x | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | Linux | ||
| Host: | Target: | ||
| Build: | |||
In the same situation GNU awk terminates with the message:
awk: cmd. line:1: (FILENAME=- FNR=1) fatal: NF set to negative value
We could to something similar by adding a couple of lines to the function handle_special in editors/awk.c:
if (v == intvar[NF]) {
n = (int)getvar_i(v);
+ if (n < 0)
+ syntax_error("NF set to negative value");
fsrealloc(n);
Fixed in git, thanks! |
Using busybox 1.28.3, echo 1 2 3 | awk 'BEGIN { NF-- }' echo | awk '{ NF-- }' Will segfault awk. Whenever NF becomes negative, awk crashes.