[git commit] cut: prevent infinite loop if -F REGEX matches empty delimiter
Denys Vlasenko
vda.linux at googlemail.com
Fri Dec 13 18:13:20 UTC 2024
commit: https://git.busybox.net/busybox/commit/?id=9adafbc1184a413999e7c8bbfc2de85bda3e0b97
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master
function old new delta
cut_main 1339 1348 +9
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
coreutils/cut.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/coreutils/cut.c b/coreutils/cut.c
index 1e9867858..e12c56732 100644
--- a/coreutils/cut.c
+++ b/coreutils/cut.c
@@ -228,7 +228,9 @@ static void cut_file(FILE *file, const char *delim, const char *odelim,
continue;
}
end = next + rr.rm_so;
- next += rr.rm_eo;
+ next += (rr.rm_eo ? rr.rm_eo : 1);
+ /* ^^^ advancing by at least 1 prevents infinite loops */
+ /* testcase: echo "no at sign" | cut -d'@*' -F 1- */
} else
#endif
{
More information about the busybox-cvs
mailing list