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>
This commit is contained in:
parent
a4894eaf71
commit
9adafbc118
1 changed files with 3 additions and 1 deletions
|
@ -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
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue