From owner-svn-src-head@freebsd.org Tue Jan 3 16:25:53 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 703BEC9D61A for ; Tue, 3 Jan 2017 16:25:53 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from nm15-vm2.bullet.mail.ne1.yahoo.com (nm15-vm2.bullet.mail.ne1.yahoo.com [98.138.91.91]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 41CDB1EF1 for ; Tue, 3 Jan 2017 16:25:53 +0000 (UTC) (envelope-from pfg@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1483460932; bh=A2BbaeLK8hnAH2NBMF2aib0Lr12GVtpkufy0rrRrkDU=; h=Subject:To:References:Cc:From:Date:In-Reply-To:From:Subject; b=SstYwXCkwQdOdEfvGo/vjiGQaDmv/aETbSwt4E/lk3Zwi5x8ZaFgSCDvTRvmSRuMn0yBkpo+ItS/PKtDfI4LzDlBlTwSg5Ow2z7JifK6cT0ZQ6x4p6kYDQk3/e40S8f9Y4rMeHch1xXkp2A4mSrUGepibRO9/7DVU+pSTPGqRm/FgE314UX8eYWOZF7F/3RzaFmeVo6r5Qo2MNCJpm9wYQ+zEFQ8+CvSP7Av8YDtF0rhzNxGisPsgIa/u3IkPorWXTBOulQUp71FhFCI3XtEwJakgnJJDpOSLMrnoOeN7kjINHU3Osn+D97vo332hKj8zXu8eMETDwZ18fBYsfUQog== Received: from [98.138.100.113] by nm15.bullet.mail.ne1.yahoo.com with NNFMP; 03 Jan 2017 16:28:52 -0000 Received: from [98.138.226.60] by tm104.bullet.mail.ne1.yahoo.com with NNFMP; 03 Jan 2017 16:25:46 -0000 Received: from [127.0.0.1] by smtp211.mail.ne1.yahoo.com with NNFMP; 03 Jan 2017 16:25:46 -0000 X-Yahoo-Newman-Id: 650834.75363.bm@smtp211.mail.ne1.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: A00o1msVM1mjEmwiK2Rexvx8VnW3W.rcErgxbBAHcqXH0L6 Zc3wyV2x6bOteitc0mPcFS4Yvj6OK0euRPHMpR9irCc3IfFEPDNABOuUOy7M jVwp87ClKf1xs5NMyA1E.YdPmEqkLpcaLqjO5GsG6JX1ApmRwhJxjGazLfi7 atmB7uahg6L5Orn2Tpm_g.M2ydrMNjywzF1_AbFd0LfJVAWKfG3dO7D4GPON XG_5bQwVR.aNAXwgbmdlesImb7DOBHqzL0YMMUBhwwRQVIXQhfsPNzABxK38 vyuRaD_9Zt30PxLkR5b5uPfdR4VDGFMiI4cpBDUHSR_f9riXW7XHty3x10Lk dXG6fROgsf5ivDs.W6C672VUZhLe7d1Ap7BoxaSxGmRn9VDpe3LATIQPfSno WmA3DYE4vG4uA8U3HMFPNyUU6aB1YVvDd8p5Fs9hFb.HHAfp_zf_Roj0o4hR 5cpTbCch5D3PFHMmBVWyxt2qVwRP_97T089kB_mwMuR7inB0AX3uBb_BY8fR TXlm8scT4NH5BqdAMK00mdm13PoZ7weZFSg2qfdlbN_rVVes- X-Yahoo-SMTP: xcjD0guswBAZaPPIbxpWwLcp9Unf Subject: Re: svn commit: r311109 - head/usr.bin/patch To: Konstantin Belousov , Ian Lepore References: <201701021823.v02INWXc028047@repo.freebsd.org> <9c3fc378-ee5e-19ba-c286-1440d4b13615@FreeBSD.org> <20170103102622.GO1923@kib.kiev.ua> <1483458723.16152.107.camel@freebsd.org> <20170103160401.GT1923@kib.kiev.ua> Cc: Conrad Meyer , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org From: Pedro Giffuni Message-ID: Date: Tue, 3 Jan 2017 11:27:28 -0500 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <20170103160401.GT1923@kib.kiev.ua> Content-Type: text/plain; charset=koi8-r; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Jan 2017 16:25:53 -0000 On 01/03/17 11:04, Konstantin Belousov wrote: > On Tue, Jan 03, 2017 at 08:52:03AM -0700, Ian Lepore wrote: >> On Tue, 2017-01-03 at 12:26 +0200, Konstantin Belousov wrote: >>> On Mon, Jan 02, 2017 at 07:41:26PM -0500, Pedro Giffuni wrote: >>>> >>>> >>>> >>>> On 01/02/17 17:54, Conrad Meyer wrote: >>>>> >>>>> I was suggesting using UINT32_MAX/2 on all platforms (which is >>>>> safe >>>>> everywhere). >>>>> >>>> Ah OK. INT_MAX is ~ (UINT_MAX / 2) so it's the same to use either. >>>> I just think it's clearer to use INT_MAX and the corresponding int >>>> type. >>>> >>>> The other issue is if diff(1) can handle such lines(?). >>> Of course it cannot, on ILP32 arches. >>> >> >> I kind of don't understand the premise of the naysayers in this thread. >> Some machines cannot do lines that are UINT_MAX long, so in that case >> we should not support any lines longer than USHORT_MAX? As if there >> aren't *billions* of line length limits to choose from between those >> two numbers? >> >> I'm also trying to picture the real-world need to diff and patch lines >> of ascii text longer than 64K, but for every problem out there, there >> is someone with a perverse need to solve that problem outside of the >> normal lines we all live between. > > The original disallow of lines longer than USHORT_MAX can be reasonably > interpreted as an attempt to only process patches which have sensible > data. The test for UINT_MAX or INT_MAX have no sense at all: what > should that check prevent ? On 32bit arches, malloc(3) is guaranteed > to fail for such large requests (for typical memory maps, malloc(3) > would be unable to allocate even 1G), for 64bit arches this is still an > artificial limitation. > I think this is a valid reason to leave things as they are. FWIW, both NetBSD and OpenBSD seem be fine with just SHORT_MAX. Given the default width in GNU diff is 130, exceeding USHORT_MAX means the tool is not being used for code. As you say, another question is if we should be limiting the use of patch(1) for code only. > Might be this is an attempt to provide DoS mitigation ? It is > probably too naive for that. > > In other words, I do see some reasoning in UINT_SHORT limit, is it useful > goal or not, is another question. While the check for INT_MAX does not > provide any value, IMO. > The check is basically a post-mortem attempt, it is of little relevance and the other BSDs don't have it. Pedro.