summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortb <tb@openbsd.org>2017-12-20 21:08:06 +0000
committertb <tb@openbsd.org>2017-12-20 21:08:06 +0000
commitc01ab2b89f9bb6c3cadec364bc9c6eb1333cc34f (patch)
tree537aa15e289efc073e88611a6b9be6cb916c787f
parentAlways 'send' host-name, rather than relying on dhclient.conf to ask (diff)
downloadwireguard-openbsd-c01ab2b89f9bb6c3cadec364bc9c6eb1333cc34f.tar.xz
wireguard-openbsd-c01ab2b89f9bb6c3cadec364bc9c6eb1333cc34f.zip
Fix adding and removing files with git-style a/ b/ diffs: only skip
six letters if they actually match "--- a/" and "+++ b/" instead of laxer checks. ok tom, tedu, millert
-rw-r--r--usr.bin/patch/pch.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/usr.bin/patch/pch.c b/usr.bin/patch/pch.c
index cc9047cfa8c..539754d814b 100644
--- a/usr.bin/patch/pch.c
+++ b/usr.bin/patch/pch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pch.c,v 1.58 2017/05/30 06:55:40 florian Exp $ */
+/* $OpenBSD: pch.c,v 1.59 2017/12/20 21:08:06 tb Exp $ */
/*
* patch - a program to apply diffs to original files
@@ -301,14 +301,16 @@ intuit_diff_type(void)
&names[OLD_FILE].exists, strippath);
else if (strnEQ(s, "--- ", 4)) {
size_t off = 4;
- if (piece_of_git && strippath == 957)
+ if (piece_of_git && strippath == 957 &&
+ strnEQ(s, "--- a/", 6))
off = 6;
names[NEW_FILE].path = fetchname(s + off,
&names[NEW_FILE].exists, strippath);
} else if (strnEQ(s, "+++ ", 4)) {
/* pretend it is the old name */
size_t off = 4;
- if (piece_of_git && strippath == 957)
+ if (piece_of_git && strippath == 957 &&
+ strnEQ(s, "+++ b/", 6))
off = 6;
names[OLD_FILE].path = fetchname(s + off,
&names[OLD_FILE].exists, strippath);