Using busybox 1.28.3, echo 1 2 3 | awk 'BEGIN { NF-- }' echo | awk '{ NF-- }' Will segfault awk. Whenever NF becomes negative, awk crashes.
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!