summaryrefslogtreecommitdiffstats
path: root/usr.bin/patch (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Accommodate POSIX basename(3) that takes a non-const parameter andnaddy2020-10-121-4/+15
| | | | | may modify the string buffer. From Joerg Sonnenberger for DragonFly BSD. ok millert@
* Merge existing decls and decls introduced in rev 1.10jca2019-12-111-11/+9
| | | | | | | | Also: - sort declarations in the same order as definitions in pch.c - delete an extra pfetch() declaration ok tobias@
* Move RCS Id to the top of the filejca2019-12-091-1/+2
|
* Tweak previous, using fputs here was finejca2019-12-021-2/+2
|
* Use getline(3) to handle lines longer than 8192 bytes in patch filesjca2019-12-026-51/+62
| | | | | Spotted by jsg@ when working on mesa. Diff tested by sthen@ in a partial i386 bulk. Input from and ok jsg@ millert@
* signal handlers should not call exit() due to possibility of reenteringderaadt2019-08-172-8/+25
| | | | | libc (stdio etc), instead do the unlink tasks then call _exit() instead ok millert
* When system calls indicate an error they return -1, not some arbitraryderaadt2019-06-283-14/+14
| | | | | | value < 0. errno is only updated in this case. Change all (most?) callers of syscalls to follow this better, and let's see if this strictness helps us in the future.
* mkstemp() returns -1 on failurederaadt2019-06-281-5/+5
|
* Delete unnecessary <libgen.h> #includesguenther2018-12-301-2/+1
| | | | ok deraadt@
* Add --dry-run as synonym to -C/--check.zhuk2018-06-222-4/+5
| | | | | | | FreeBSD and NetBSD has this for a while, and GNU patch got it even earlier than we got -C. input from sthen@ & jca@; okay sthen@, jca@ and deraadt@.
* Use <fcntl.h> instead of <sys/file.h> for open() and friends.guenther2018-04-261-4/+2
| | | | | | | Delete a bunch of unnecessary #includes and sort to match style(9) while doing the above cleanup. ok deraadt@ krw@
* Stop telling patch(1) runs ed(1).zhuk2018-04-111-8/+2
| | | | okay tb@ and benno@
* Remove unused pathnames.h header since patch was refactoring into not invokinganton2018-04-074-17/+4
| | | | ed back in 2015; ok millert@ tb@ tobias@
* Fix adding and removing files with git-style a/ b/ diffs: only skiptb2017-12-201-3/+5
| | | | | | | six letters if they actually match "--- a/" and "+++ b/" instead of laxer checks. ok tom, tedu, millert
* rejname[] is also -r option buffer, and should be PATH_MAXderaadt2017-06-121-2/+2
| | | | ok millert
* Unbreak previous for git diffs that do not have the a/ prefix.florian2017-05-301-2/+2
| | | | Found the hard way be me, OK tedu
* sometimes patches coming from other places have extra a/ and b/ directoriestedu2017-05-261-7/+15
| | | | | prepended to filenames. detect this condition and attempt to correct it. ok openbsd
* One string buffer can use recallocarray() to ensure that the address spacederaadt2017-03-261-2/+2
| | | | | doesn't get dribbled with known contents. ok otto millert tobias
* parameter "lines_allocated" is a local pointer and should not be confusedderaadt2017-03-251-5/+5
| | | | with the global by the same name, so rename it "lines_allocatedp".
* Fix 'c'hange command handling if last line of a file is removed.tobias2016-09-021-2/+3
| | | | | | | If the last line of a file is removed, the line cache is erroneously considered empty, which means that changed lines are added at the top. spotted by and okay otto@
* If reading fails, do not go into infinite loop asking for a filenameotto2016-09-021-3/+5
| | | | | Happens in bulf build where no tty is available. ok sthen@ naddy@ $(jot -b yes 1000) landry@
* Cleanup close(open idioms.deraadt2016-07-191-2/+6
| | | | ok krw
* Properly handle ed-files which fully replace input file content. Thistobias2016-02-221-18/+11
| | | | | | | | misbehaviour is triggered with 'c' and 'i' commands on empty buffers. Spotted and fixed by Martin Natano <natano at natano dot net>. ok millert@
* usage() should exit 2 here, not EXIT_SUCCESSgsoares2016-01-041-2/+2
| | | | ok tb@
* fix exit status on pledge(2) failure.gsoares2015-12-291-2/+2
| | | | OK tb@ jsg@
* exit() after perror() for pledge failure. Perhaps this got introducedderaadt2015-11-111-2/+4
| | | | | as a test idiom, either when pledge was young or during the transition to strings.... dunno
* creat() -> open equiv; from Frederic Nowakderaadt2015-11-111-2/+2
|
* Add native support for ed-style diffs. No need to pledge "proc exec" anymore.tobias2015-10-166-96/+386
| | | | ok deraadt
* Change all tame callers to namechange to pledge(2).deraadt2015-10-091-3/+3
|
* patch(1) can move to "stdio rpath wpath cpath tmppath fattr proc exec"deraadt2015-10-071-2/+2
| | | | | | | | | | | | | (adding proc exec), now that "exec" has arrived in the kernel. This permits the dangerous game of feeding ed-style diffs with popen() via /bin/ed. Shocked yet? Your mission, should you choose to accept it, is to replace this code with an builtin ed-style patcher, maybe cribbing code from ed itself. I'm sorry, but we can't fix the entire world all at once. Noone loves deprecating standarized features as much as we do, but there are some lines. Maybe if people become aware of how crappy the implimentations of some standard features are, they could help decide the path.
* remove tame "proc". it is not useful, because the "ed" diffs requirederaadt2015-10-041-2/+2
| | | | | | fork+execve, and execve is not going to become available in this fashion. ed diffs should be handled using a built-in handler, and various folks have been discussing this behind the scenes.
* As pointed out by tobiasu, ed-style patches still use popen() and executederaadt2015-10-031-2/+2
| | | | | | | | | /bin/ed. This is RETARDED. Nothing learned from the last year? Add tame "proc" until that is fixed, to allow fork+exec. I beg for someone to cross-link the guts of ed directly into patch, or write a ed-subset which can do the job.
* patch appears to work fully with tame "stdio rpath wpath cpath tmppath fattr".deraadt2015-10-031-1/+4
| | | | | | in case of exploitation, no more network access, fork, execve, etc. I wonder if we could use whitepath lists here - if it is reasonable to limit operation in directories known early on?
* Account for newlines in substitution (s///) commands. Substitutionmillert2015-07-311-2/+14
| | | | | | | | commands might contain a newline in the replacement pattern (escaped with a backslash before it), causing patch's understanding of the state the ed child process is in to diverge from reality. This can lead to patch unwillingly feeding '!' (execute shell command) lines to ed. From Martin Natano. OK deraadt@
* Remove support for automatically checking files out of RCS. Themillert2015-07-266-133/+20
| | | | | behavior is confusing to users and even GNU patch no longer does it by default. OK krw@ guenther@
* remove the first comma from constructs like ", and," and ", or,": you can usejmc2015-03-131-3/+3
| | | | | "and" and "or" to join sentence clauses, and you can use commas, but both hinders reading;
* Include stdint.h, not limits.h to get SIZE_MAX. OK guenther@millert2015-02-052-3/+4
|
* Replace <sys/param.h> with <limits.h> and other less dirty headers wherederaadt2015-01-161-4/+3
| | | | | | | | | possible. Annotate <sys/param.h> lines with their current reasons. Switch to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where sensible to avoid pulling in the pollution. These are the files confirmed through binary verification. ok guenther, millert, doug (helped with the verification protocol)
* Handle ed command "s" as a one line command, which it is.tobias2014-12-141-3/+3
| | | | | | Prevents arbitrary ed command executions in following lines. ok millert
* The function savestr allows NULL return values during Plan A patching so intobias2014-12-134-17/+34
| | | | | | case of out of memory conditions, Plan B can step in. In many cases, NULL value is not properly handled, so use xstrdup here (it's outside Plan A/B patching, which means that even Plan B relies on successful operations).
* Fix division by zero for files with long lines (> 1024) in Plan B modetobias2014-12-091-19/+37
| | | | | | by supporting arbitrarily long lines just like Plan A does. ok tedu
* spacesderaadt2014-12-082-5/+5
|
* three trivial reallocarray() usesderaadt2014-12-011-4/+4
|
* Prefer setvbuf() to setlinebuf() for portability; ok deraadt@millert2014-11-261-3/+3
|
* Properly validate line ranges supplied in diff file to prevent overflows.tobias2014-11-261-4/+27
| | | | | | | Also fixes an out of boundary memory access because the resulting values are used as array indices. ok millert
* Introduce strtolinenum to properly check line numbers while parsing:tobias2014-11-252-33/+51
| | | | | | no signs, no spaces, just digits, 0 <= x <= LONG_MAX ok millert, otto
* Prevent null pointer dereference on empty input files when diff requirestobias2014-11-251-2/+2
| | | | | | a specific version. ok millert
* Remove SCCS support. For this to work, we would need "get", which we don'ttobias2014-11-225-23/+12
| | | | | | even have in ports. XSI functionality of POSIX, therefore optional. ok deraadt, schwarze, tedu
* Remove the README. It history from more than 20 years ago, and whilederaadt2014-11-211-123/+0
| | | | | interesting it has no impact on the maintainance of this stuff. ok tobias
* Avoid iterating over end of string.tobias2014-11-181-3/+3
| | | | ok millert, otto