On Thursday 19 August 2010 15:50, Colin Watson wrote: > If the supplied pattern matches the empty string at the start of a line, > then 'grep -o' would loop forever. > > Originally reported as > https://bugs.launchpad.net/ubuntu/+source/busybox/+bug/619817. > > Signed-off-by: Colin Watson <[email protected]> > --- > findutils/grep.c | 20 +++++++++++++------- > testsuite/grep.tests | 4 ++++ > 2 files changed, 17 insertions(+), 7 deletions(-) > > diff --git a/findutils/grep.c b/findutils/grep.c > index 688ea6a..7545ade 100644 > --- a/findutils/grep.c > +++ b/findutils/grep.c > @@ -463,13 +463,19 @@ static int grep_file(FILE *file) > } else while (1) { > unsigned end = > gl->matched_range.rm_eo; > char old = line[end]; > - line[end] = '\0'; > - print_line(line + > gl->matched_range.rm_so, > - end - > gl->matched_range.rm_so, > - linenum, ':'); > - if (old == '\0') > - break; > - line[end] = old; > + if (gl->matched_range.rm_so == > gl->matched_range.rm_eo) { > + end++;
Why do you think end++ does not run off the end of the line? > + if (line[end] == '\0') > + break; -- vda _______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
