Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 5 Apr 2017 20:11:05 +0000 (UTC)
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r316542 - head/usr.bin/grep
Message-ID:  <201704052011.v35KB55U047285@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: emaste
Date: Wed Apr  5 20:11:05 2017
New Revision: 316542
URL: https://svnweb.freebsd.org/changeset/base/316542

Log:
  bsdgrep: Handle special case of single-byte NUL pattern
  
  PR:		202022
  Submitted by:	Kyle Evans <kevans91 at ksu.edu>
  MFC after:	1 month
  Differential Revision:	https://reviews.freebsd.org/D10102

Modified:
  head/usr.bin/grep/grep.c

Modified: head/usr.bin/grep/grep.c
==============================================================================
--- head/usr.bin/grep/grep.c	Wed Apr  5 19:52:49 2017	(r316541)
+++ head/usr.bin/grep/grep.c	Wed Apr  5 20:11:05 2017	(r316542)
@@ -314,8 +314,12 @@ read_patterns(const char *fn)
 	}
 	len = 0;
 	line = NULL;
-	while ((rlen = getline(&line, &len, f)) != -1)
+	while ((rlen = getline(&line, &len, f)) != -1) {
+		if (line[0] == '\0')
+			continue;
 		add_pattern(line, line[0] == '\n' ? 0 : (size_t)rlen);
+	}
+
 	free(line);
 	if (ferror(f))
 		err(2, "%s", fn);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201704052011.v35KB55U047285>