aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/patch
diff options
context:
space:
mode:
authorKyle Evans <kevans@FreeBSD.org>2018-01-11 15:01:48 +0000
committerKyle Evans <kevans@FreeBSD.org>2018-01-11 15:01:48 +0000
commit21ab148d783814f0157935e3fd210b2f22cdb00f (patch)
tree9a2330f09335fdbae5b54988ca0c617405b0cbfd /usr.bin/patch
parent767754e5ab2fde9c65f71e32f08f08846d5122cf (diff)
Notes
Diffstat (limited to 'usr.bin/patch')
-rw-r--r--usr.bin/patch/inp.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/usr.bin/patch/inp.c b/usr.bin/patch/inp.c
index 2c955d0c8377..6a01f782ce62 100644
--- a/usr.bin/patch/inp.c
+++ b/usr.bin/patch/inp.c
@@ -213,8 +213,11 @@ plan_a(const char *filename)
/* now scan the buffer and build pointer array */
iline = 1;
i_ptr[iline] = i_womp;
- /* test for NUL too, to maintain the behavior of the original code */
- for (s = i_womp, i = 0; i < i_size && *s != '\0'; s++, i++) {
+ /*
+ * Testing for NUL here actively breaks files that innocently use NUL
+ * for other reasons. mmap(2) succeeded, just scan the whole buffer.
+ */
+ for (s = i_womp, i = 0; i < i_size; s++, i++) {
if (*s == '\n') {
if (iline == lines_allocated) {
if (!reallocate_lines(&lines_allocated))