diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2024-12-13 19:06:58 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2024-12-13 19:13:20 +0100 |
commit | 9adafbc1184a413999e7c8bbfc2de85bda3e0b97 (patch) | |
tree | 0419eba6b98d4a223bc3442f23ff1cc4918514e1 | |
parent | a4894eaf713f0e452c272db1c5dc2a459e05808f (diff) | |
download | busybox-w32-9adafbc1184a413999e7c8bbfc2de85bda3e0b97.tar.gz busybox-w32-9adafbc1184a413999e7c8bbfc2de85bda3e0b97.tar.bz2 busybox-w32-9adafbc1184a413999e7c8bbfc2de85bda3e0b97.zip |
cut: prevent infinite loop if -F REGEX matches empty delimiter
function old new delta
cut_main 1339 1348 +9
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | coreutils/cut.c | 4 |
1 files changed, 3 insertions, 1 deletions
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, | |||
228 | continue; | 228 | continue; |
229 | } | 229 | } |
230 | end = next + rr.rm_so; | 230 | end = next + rr.rm_so; |
231 | next += rr.rm_eo; | 231 | next += (rr.rm_eo ? rr.rm_eo : 1); |
232 | /* ^^^ advancing by at least 1 prevents infinite loops */ | ||
233 | /* testcase: echo "no at sign" | cut -d'@*' -F 1- */ | ||
232 | } else | 234 | } else |
233 | #endif | 235 | #endif |
234 | { | 236 | { |