freebsd-skq/usr.bin/patch
kevans 0b87c9f682 patch(1): Don't check for NUL bytes in Plan A
Plan A mmap()'s the entire input file and operates on it in memory. The
map(2) call succeeded, so we shouldn't need to bother checking for the NUL
byte as long as we're within our buffer space.

This was clearly intentional to match "the behavior of the original code",
but it creates a discrepancy between Plan A and Plan B that doesn't seem
sensible and it's not inherently wrong to allow a NUL byte.

This change was motivated by the gemspec in net/rubygem-grpc failing to
patch, despite the patch being generated with diff, because a NUL byte was
used as a delimiter in the header briefly in an otherwise text file.

An alternative was considered: to fallback to plan B if plan A won't process
the entire file due to a NUL byte, but I deemed this to be the better option
since plan A isn't failing due to memory limitations and will fail later on
if it's really dealing with a file it shouldn't be.

PR:		224842 (exp-run)
Reported by:	swills
Reviewed by:	emaste, pfg
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D13738
2018-01-11 15:01:48 +00:00
..
backupfile.c
backupfile.h
common.h patch(1): make some macros look boolean. 2016-10-01 20:46:01 +00:00
inp.c patch(1): Don't check for NUL bytes in Plan A 2018-01-11 15:01:48 +00:00
inp.h
Makefile
Makefile.depend DIRDEPS_BUILD: Update dependencies. 2017-10-31 00:07:04 +00:00
mkpath.c General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
patch.1 Remove automatic checkout feature. 2015-08-15 00:42:33 +00:00
patch.c patch: rejname[] is also -r option buffer, and should be PATH_MAX. 2017-12-21 16:19:10 +00:00
pathnames.h
pch.c patch: further cleanup to git-style diffs. 2017-12-21 16:25:33 +00:00
pch.h Revert r311106: 2017-01-02 18:23:31 +00:00
util.c Remove automatic checkout feature. 2015-08-15 00:42:33 +00:00
util.h Remove automatic checkout feature. 2015-08-15 00:42:33 +00:00