History log of /netbsd-src/usr.bin/patch/pch.c (Results 1 – 25 of 34)
Revision Date Author Comments
# 923fe307 12-Jul-2024 manu <manu@NetBSD.org>

Let patch(1) handle lines of length beyond INT16_MAX

Borrowed from OpenBSD
https://marc.info/?l=openbsd-bugs&m=168907249732754


# a874c40b 16-Jun-2023 wiz <wiz@NetBSD.org>

Comment out variable assignations that are not used.

Remove trailing whitespace.


# 9265e94b 25-May-2021 cjep <cjep@NetBSD.org>

As per OpenBSD, use malloc for the line buffer. Fixes the known issue
with long lines and makes our ATF test suite pass fully.
Closes PR bin/54620 from coypu who suggested the approach.
Reviewed by c

As per OpenBSD, use malloc for the line buffer. Fixes the known issue
with long lines and makes our ATF test suite pass fully.
Closes PR bin/54620 from coypu who suggested the approach.
Reviewed by christos.

show more ...


# d36fee1b 17-Nov-2020 rhialto <rhialto@NetBSD.org>

Remove heuristic for dealing with trailing newlines being truncated by mailers.

Patch and explanation taken from bsdimp:
https://bsdimp.blogspot.com/2020/08/a-35-year-old-bug-in-patch-found-in.html

Remove heuristic for dealing with trailing newlines being truncated by mailers.

Patch and explanation taken from bsdimp:
https://bsdimp.blogspot.com/2020/08/a-35-year-old-bug-in-patch-found-in.html
https://svnweb.freebsd.org/base?view=revision&revision=364291

Every version of patch since the first one posted to mod.sources in 1985 have
included a heuristic for coping with the state of email messaging at the
time. This heuristic would add up to 4 blank lines to a patch if it thought it
needed it. The trouble is, though this causes at least one bug.

The bug in my case is that if you have a context diff whose last hunk only
deletes 3 or fewer lines, then if you try to reverse apply it with -R, it will
fail. The reason for this is the heuristic builds an internal representation
that includes those blank lines. However, it should really replicate the lines
from the pattern lines line it would any other time, not assume they are blank
lines. Removing this heuristic will prevent patch from misapplying the lines
removed after applying a 'fuzz' factor to the previous blank line in the file. I
believe this will only affect 'new-style' 4.3BSD context diffs and not the
older-style 4.2BSD diffs and plain, non-context diffs. It won't affect any of
the newer formats, since they don't use the 'omitted' construct in the same way.

Since this heuristic was put into patch at a time when email / etc ate trailing
white space on a regular basis, and since it's clear that this heuristic is the
wrong thing to do at least some of the time, it's better to remove it
entirely. It's not been needed for maybe 20 years since patch files are not
usually corrupted. If there are a small number of patch files that would benefit
from this corruption fixing, those already-currupt patches can be fixed by the
addition of blank lines. I'd wager that no one will ever come to me with an
example of a once-working patch file that breaks with this change. However, I
have 2 patches from the first 195 patches to 2.11BSD that are affected by this
bug, suggesting that the relative frequency of the issue has changed
signficantly since the original heuristic was put into place.

show more ...


# a2ee17b3 18-Jun-2018 christos <christos@NetBSD.org>

Keep things portable (requested by joerg) by not depending on reallocarr
and instead doing the overflow check ourselves.


# 019d365a 05-Apr-2018 christos <christos@NetBSD.org>

Pass -S to ed(1) so that patches containing ! commands don't run commands.
Real cause of CVS-2018-0492:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=894667)


# e139f8ac 30-Jul-2015 christos <christos@NetBSD.org>

from bitrieg:

Substitution 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

from bitrieg:

Substitution 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. Finding out how to do this is left as an exercise to the reader.

XXX: pullup-7

show more ...


# 938d39fd 27-Nov-2014 christos <christos@NetBSD.org>

PR/49422: Ryo ONODERA: patch(1) cannot handle context diffs


# 59de2004 26-Nov-2014 christos <christos@NetBSD.org>

Avoid coredumps when the linenumbers in the hunks turn negative.
From: http://marc.info/?l=openbsd-tech&m=141693055412785

XXX: pullup 7


# b5609ab0 29-Jan-2013 wiz <wiz@NetBSD.org>

Add comma after i.e.
From Bug Hunting.


# d5bd9463 06-Sep-2011 joerg <joerg@NetBSD.org>

Consistently use __dead and __printflike.


# d5b2c9a8 19-Sep-2008 joerg <joerg@NetBSD.org>

Update patch to the version used by DragonFly and derived from OpenBSD.
Major changes are:
- better detection of double applied patches
- rejects remain unified diffs for unified patches
- far less l

Update patch to the version used by DragonFly and derived from OpenBSD.
Major changes are:
- better detection of double applied patches
- rejects remain unified diffs for unified patches
- far less limitations, e.g. patch lines may be arbitrary long

This addresses PR standards/11220 by changing patch -b behavior to be
POSIX compliant. Old behavior can be obtained using --suffix, which
works since NetBSD 1.4. pkgsrc has been adjusted accordingly.

show more ...


# 1e1f0dd3 26-Sep-2006 christos <christos@NetBSD.org>

PR/34627: Lubomir Kundrak: patch(1) segfaults, when fed from stdin in batch
or force mode


# 04e2c897 24-May-2006 christos <christos@NetBSD.org>

Coverity CID 3510: Don't leak memory.


# 5800a551 09-Apr-2006 christos <christos@NetBSD.org>

Coverity CID 2078, 2079, 2080: Plug memory leaks.


# 75c32b46 30-Jul-2003 itojun <itojun@NetBSD.org>

use bounded string op


# ef4b3d62 12-Jul-2003 itojun <itojun@NetBSD.org>

copyright missing in files, copy them from README


# 158e4448 01-Jun-2003 kristerw <kristerw@NetBSD.org>

Shorten long lines.
Some whitespace changes to get closer to KNF.


# b86c323d 30-May-2003 kristerw <kristerw@NetBSD.org>

Simplify handling of memory allocation, and make sure all return values
from malloc etc. are handled.

This removes the old behavior to retry the operation with a less memory-
consuming method in cas

Simplify handling of memory allocation, and make sure all return values
from malloc etc. are handled.

This removes the old behavior to retry the operation with a less memory-
consuming method in case malloc failed (this mechanism has never really
worked, and is hard to test. Besides, it is less useful now than it was
20 years ago when the code was written...)

show more ...


# 2a9882e7 29-May-2003 kristerw <kristerw@NetBSD.org>

Be consistent with use of types (e.g. do not use LINENUM for quantities
that are not line numbers).


# 5ca06f36 20-Apr-2003 christos <christos@NetBSD.org>

PR/5123: Ignatios Souvatzis: make patch exit gracefully on malformed input.


# f3dbc98b 24-Mar-2002 kristerw <kristerw@NetBSD.org>

Handle patches in which diff(1) has added lines saying
"\ No newline at end of file"


# ec7291ab 16-Mar-2002 kristerw <kristerw@NetBSD.org>

Don't leak memory if realloc fails
Spell "FALLTHROUGH" correctly


# 93318b47 16-Mar-2002 kristerw <kristerw@NetBSD.org>

Check result of malloc and strdup
Made some functions static
Removed unneccessary buffer
Increased size of some buffers that could overflow


# 774d6dd9 15-Mar-2002 kristerw <kristerw@NetBSD.org>

KNF


12