From MAILER-DAEMON Thu Jan 12 11:12:27 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cRhzH-00034P-EB
	for mharc-bug-patch@gnu.org; Thu, 12 Jan 2017 11:12:27 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:42057)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bruno@clisp.org>) id 1cRhzF-00032g-7p
	for bug-patch@gnu.org; Thu, 12 Jan 2017 11:12:26 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <bruno@clisp.org>) id 1cRhzA-0001Xt-5U
	for bug-patch@gnu.org; Thu, 12 Jan 2017 11:12:25 -0500
Received: from mo6-p00-ob.smtp.rzone.de ([2a01:238:20a:202:5300::12]:26668)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <bruno@clisp.org>) id 1cRhz9-0001Vj-S6
	for bug-patch@gnu.org; Thu, 12 Jan 2017 11:12:20 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1484237538;
	l=1096; s=domk; d=clisp.org;
	h=Content-Type:Content-Transfer-Encoding:MIME-Version:Date:Subject:To:
	From; bh=z6CKGCW5HfvjW+685/O1jFnE7qPGQpBpe6VDL3nquBs=;
	b=bOVb+cIRU0byGQbzizpQDqpLbYHnqG41Eh5g5ueFGhnAH97ogVRzxK99l1cBxkR/Na
	NgcuSb6aPGXEswSS5lPxaLEYaZMITK+hVhi35L4Q9n7LnaPOn4KdydLhIPk9jJB92lH4
	jRRbev9GnjiiVWMmnT5AX52NLzS0Fi1tyOgyo=
X-RZG-AUTH: :Ln4Re0+Ic/6oZXR1YgKryK8brksyK8dozXDwHXjf9hj/zDNRavU46kji
X-RZG-CLASS-ID: mo00
Received: from bruno.haible.de
	(dslb-088-068-033-080.088.068.pools.vodafone-ip.de [88.68.33.80])
	by smtp.strato.de (RZmta 39.11 DYNA|AUTH)
	with ESMTPSA id 408ea7t0CG5vDL1
	(using TLSv1 with cipher ECDHE-RSA-AES256-SHA (curve secp521r1 with 521
	ECDH bits, eq. 15360 bits RSA))
	(Client did not present a certificate);
	Thu, 12 Jan 2017 17:05:57 +0100 (CET)
From: Bruno Haible <bruno@clisp.org>
To: bug-patch@gnu.org
Date: Thu, 12 Jan 2017 17:05:56 +0100
Message-ID: <2516894.cLZTo6oi2W@linuix.haible.de>
User-Agent: KMail/4.8.5 (Linux/3.8.0-44-generic; KDE/4.8.5; x86_64; ; )
MIME-Version: 1.0
Content-Transfer-Encoding: 7Bit
Content-Type: text/plain; charset="us-ascii"
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic]
X-Received-From: 2a01:238:20a:202:5300::12
Subject: [bug-patch] patch rejects file names starting with '../' as
 "invalid"
X-BeenThere: bug-patch@gnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: "Bug reports, suggestions,
	general discussion for GNU patch." <bug-patch.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-patch>,
	<mailto:bug-patch-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/bug-patch/>
List-Post: <mailto:bug-patch@gnu.org>
List-Help: <mailto:bug-patch-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-patch>,
	<mailto:bug-patch-request@gnu.org?subject=subscribe>
X-List-Received-Date: Thu, 12 Jan 2017 16:12:26 -0000

Hi,

With patch 2.7.5 I have to make contortions in order to transport a set
of hunks from one file to another:

$ git diff vacall.h.in | patch ../callback/vacall_r/vacall_r.h.in
Invalid file name ../callback/vacall_r/vacall_r.h.in -- skipping patch

$ git diff vacall.h.in | (cd .. && patch callback/vacall_r/vacall_r.h.in)
patching file callback/vacall_r/vacall_r.h.in
Hunk #1 succeeded at 367 (offset -1 lines).
Hunk #2 succeeded at 651 (offset -1 lines).

This worked with 2.7.1, hence it is a regression:

$ git diff vacall.h.in | patch ../callback/vacall_r/vacall_r.h.in
patching file ../callback/vacall_r/vacall_r.h.in
Hunk #1 succeeded at 367 (offset -1 lines).
Hunk #2 succeeded at 651 (offset -1 lines).

I fully agree that for security reasons, patch (like 'tar') should reject
file names that start with '../' when they originate from the patch file
(standard input in this case). But for file names given on the command line,
there is no security risk.

Suggestion: Make 'patch FILENAME' work again, regardless whether FILENAME
begins with '../'.

Bruno



From MAILER-DAEMON Thu Jan 12 11:20:03 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cRi6d-0000fP-1A
	for mharc-bug-patch@gnu.org; Thu, 12 Jan 2017 11:20:03 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:43732)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <andreas.gruenbacher@gmail.com>) id 1cRi6X-0000Xi-FF
	for bug-patch@gnu.org; Thu, 12 Jan 2017 11:20:02 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <andreas.gruenbacher@gmail.com>) id 1cRi6V-0003tf-IT
	for bug-patch@gnu.org; Thu, 12 Jan 2017 11:19:57 -0500
Received: from mail-it0-x244.google.com ([2607:f8b0:4001:c0b::244]:34820)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <andreas.gruenbacher@gmail.com>)
	id 1cRi6V-0003sf-BA
	for bug-patch@gnu.org; Thu, 12 Jan 2017 11:19:55 -0500
Received: by mail-it0-x244.google.com with SMTP id 203so2304396ith.2
	for <bug-patch@gnu.org>; Thu, 12 Jan 2017 08:19:54 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
	h=mime-version:sender:in-reply-to:references:from:date:message-id
	:subject:to:cc;
	bh=QgjMnwh+jtxNsk7q5Q+nmu4sQuMTcoNQm7f9gcsVREg=;
	b=n3t9mkdaBCPEBhzwQxLwa0uXgRh3u9h10Qp8SOvX+ZqA71jd49yhURpx89VJamHZm2
	yjgBR/EttpFfBGor+vzKgg83p/zk4PPdqfC5FMOvFhBHmHLHNYAWQvwY2GvwPSDfn75f
	2m2hUhWjqVTwSSepYwB5SPbUzxZqsN9PaABehp0T9dFmz9yPZ3Go1mW1tUqpFVfI/pUy
	xzSjdhXHLYjGrEX2GTQprz+bi90T9zDaOS6pPCajnyLCMN2tDJOGkFNQ4N5JXsaOK06k
	y0zIi8G1uHvqqk945yXjNIKDG0ocvQip7c9RIviP/k6We5L/4v0T8Rb5MQy68HA+QNQI
	USMQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:sender:in-reply-to:references:from
	:date:message-id:subject:to:cc;
	bh=QgjMnwh+jtxNsk7q5Q+nmu4sQuMTcoNQm7f9gcsVREg=;
	b=X5+DwCtlpI5y6QoD91S48o9dyl9cX9yvwQ7191WWKeNC1XWZ9jGX9/9r51jvL1G2Z0
	eW03XlVA0mWmg09h2p2C95pAneIfhVGCm5aVJoz1rjb+ixHmzFetp7DxiXDuMeefIDn9
	JuPKDIdC5Fh0FcGQQWvRRgYq88uLRdaA2Ac7UCkJ84quUJkURMNK/TYV2+/flCaFdt7Z
	mYvQgPpmgtWAc+EqqoEKNaP6mriEOCk1bG8Cg2I6s87E0KwA9QHGLZF2ba49NR+Ti8j2
	OLJq4dFz4iC28A3OrtO4sVYhdAJ3q0ALuAB8Qi97BtyS45slL0ThTHtVbYgy82/ylWbP
	XcqQ==
X-Gm-Message-State: AIkVDXJrtP5rRlQTGzxFWNuiCv2I5QX7QDIAua15kRQGNVWh42F5H2s8ZR5obl+dpPmPJ6edTrO6zOwlKhBq2A==
X-Received: by 10.36.199.198 with SMTP id t189mr10757610itg.102.1484237993952; 
	Thu, 12 Jan 2017 08:19:53 -0800 (PST)
MIME-Version: 1.0
Sender: andreas.gruenbacher@gmail.com
Received: by 10.107.6.197 with HTTP; Thu, 12 Jan 2017 08:19:53 -0800 (PST)
In-Reply-To: <2516894.cLZTo6oi2W@linuix.haible.de>
References: <2516894.cLZTo6oi2W@linuix.haible.de>
From: =?UTF-8?Q?Andreas_Gr=C3=BCnbacher?= <agruen@gnu.org>
Date: Thu, 12 Jan 2017 17:19:53 +0100
X-Google-Sender-Auth: EmlfzDy4iV0UsNFWs5mF4k9KB10
Message-ID: <CAHpGcMLva7XANZ7qC5DOhsEmAP-V6KdeaYJM=aFPE=EQ0VhG_A@mail.gmail.com>
To: Bruno Haible <bruno@clisp.org>
Cc: "bug-patch@gnu.org" <bug-patch@gnu.org>
Content-Type: text/plain; charset=UTF-8
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 2607:f8b0:4001:c0b::244
Subject: Re: [bug-patch] patch rejects file names starting with '../' as
 "invalid"
X-BeenThere: bug-patch@gnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: "Bug reports, suggestions,
	general discussion for GNU patch." <bug-patch.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-patch>,
	<mailto:bug-patch-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/bug-patch/>
List-Post: <mailto:bug-patch@gnu.org>
List-Help: <mailto:bug-patch-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-patch>,
	<mailto:bug-patch-request@gnu.org?subject=subscribe>
X-List-Received-Date: Thu, 12 Jan 2017 16:20:02 -0000

Bruno,

2017-01-12 17:05 GMT+01:00 Bruno Haible <bruno@clisp.org>:
> With patch 2.7.5 I have to make contortions in order to transport a set
> of hunks from one file to another:
>
> $ git diff vacall.h.in | patch ../callback/vacall_r/vacall_r.h.in
> Invalid file name ../callback/vacall_r/vacall_r.h.in -- skipping patch
>
> $ git diff vacall.h.in | (cd .. && patch callback/vacall_r/vacall_r.h.in)
> patching file callback/vacall_r/vacall_r.h.in
> Hunk #1 succeeded at 367 (offset -1 lines).
> Hunk #2 succeeded at 651 (offset -1 lines).
>
> This worked with 2.7.1, hence it is a regression:
>
> $ git diff vacall.h.in | patch ../callback/vacall_r/vacall_r.h.in
> patching file ../callback/vacall_r/vacall_r.h.in
> Hunk #1 succeeded at 367 (offset -1 lines).
> Hunk #2 succeeded at 651 (offset -1 lines).
>
> I fully agree that for security reasons, patch (like 'tar') should reject
> file names that start with '../' when they originate from the patch file
> (standard input in this case). But for file names given on the command line,
> there is no security risk.

I agree. This should actually be addressed by commit 83a3ed01 on
git://git.savannah.gnu.org/patch.git from last July already, can you
verify?

Thanks,
Andreas


