From owner-svn-src-head@freebsd.org Mon Jan 2 19:48:56 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 7BA9CC9CB08 for ; Mon, 2 Jan 2017 19:48:56 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from nm7-vm6.bullet.mail.ne1.yahoo.com (nm7-vm6.bullet.mail.ne1.yahoo.com [98.138.91.100]) (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 4E0F21309 for ; Mon, 2 Jan 2017 19:48:56 +0000 (UTC) (envelope-from pfg@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1483384855; bh=Jhf06kvNC8geZcr7+mW/EHMCGzQuwku4eRUdYpyMYPc=; h=Subject:To:References:Cc:From:Date:In-Reply-To:From:Subject; b=T6Kdho9ToifpaDAQJVFvhpkQzbFNEtlYFF+glMFD15oNMvEeyWIioMjNIyHVELe0yYMnCNT3Rl/6duozA/HLhI/g86v7RhyQpEAeXN3v9zNxlJzU7mO3wT9x2UgSj9uToGwHqo0OzKYhpMdMVis7+aHjRrcYnVgEIDI03xUY/eIyrccComDOeY3M0WVNo+Z3dbgN1zxpGRUjDf+kiQujUjCed7SNtzdgtpGmrRyHmGI7fvQZ8aGkwBdTmR0y8xa5SbZNi+IoXccUoHxthDOHn0rKovPjDFpJaNvQnWFlnA2swKtLHRwlQs2fziixDU82iJjvhV96m9KDbcGpv8eEqA== Received: from [98.138.101.128] by nm7.bullet.mail.ne1.yahoo.com with NNFMP; 02 Jan 2017 19:20:55 -0000 Received: from [98.138.84.47] by tm16.bullet.mail.ne1.yahoo.com with NNFMP; 02 Jan 2017 19:20:55 -0000 Received: from [127.0.0.1] by smtp115.mail.ne1.yahoo.com with NNFMP; 02 Jan 2017 19:20:55 -0000 X-Yahoo-Newman-Id: 831746.41017.bm@smtp115.mail.ne1.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: UxD6rfQVM1lkjVbG4n9QroBQjVSB3KF6paOSEzPwa7XEAJG hrh.9EzKcmcFxGLYSzz6IZoByPZh99d72g0MoEaOnuaYk9jNXF2YK.XtkFD8 SHW08KxPDKU3j7TwBp9ZDmshEVVnK1oq5qk5JKcaq.vK.xlk4D7IFe1dF2If 2xMa4fOk7TBAx._juozYhtu9XpKS8mlvo05IM7HbBwK8TJ3oix35TmV287hN cjtBdbHNxPrUs0RdzNt0qnf9b2CYFS9c2p8EM5u2YXRLeLwdf.0cVMw9wmz6 qAV51rkEdGSIgMDs8gtpnIi3eFqTWEPbBGSj.giqVu4TiFieKPW1b6OYoUC3 AicYCJPSUp7RYtzJAKm8W7iWCHffbH2k8bwlsM7hl6D8ofB15cuoazlghB4S RHoO.IWl7SVn_eL_dLFQu2azMNbWuOsJ3hFShYK0QYsE1iDRJ2nbPk9vlo9b lo504jnM1HreDvI4DREYDrvq2MCXS5tQ03dkZreKd13752scbaPCLy1rheDq ZnoD9CsWjqNmXhMk.4wOXoflp7Rn7DfstWEWv1J3.LogTVIE- X-Yahoo-SMTP: xcjD0guswBAZaPPIbxpWwLcp9Unf Subject: Re: svn commit: r311109 - head/usr.bin/patch To: cem@freebsd.org References: <201701021823.v02INWXc028047@repo.freebsd.org> Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org From: Pedro Giffuni Message-ID: Date: Mon, 2 Jan 2017 14:22:36 -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: Content-Type: multipart/mixed; boundary="------------840810EA8B3737957FA7B036" 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: Mon, 02 Jan 2017 19:48:56 -0000 This is a multi-part message in MIME format. --------------840810EA8B3737957FA7B036 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Hi; On 01/02/17 13:28, Conrad Meyer wrote: > IMO this patch was mostly fine, you just need to restrict line length > to UINT32_MAX/2 instead of UINT_MAX (== UINT32_MAX) for 32-bit > platforms. > > Best, > Conrad > I dislike the idea of special cases for some platforms. I guess moving to int/INT_MAX would be the way to go. TBH, no one has asked for patches wider than USHRT_MAX though. Pedro. --------------840810EA8B3737957FA7B036 Content-Type: text/x-patch; name="patch-intline.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="patch-intline.diff" Index: usr.bin/patch/patch.c =================================================================== --- usr.bin/patch/patch.c (revision 311110) +++ usr.bin/patch/patch.c (working copy) @@ -753,7 +753,7 @@ fprintf(rejfp, "%c%s", ch, line); if (len == 0 || line[len - 1] != '\n') { - if (len >= USHRT_MAX) + if (len >= INT_MAX) fprintf(rejfp, "\n\\ Line too long\n"); else fprintf(rejfp, "\n\\ No newline at end of line\n"); @@ -1024,7 +1024,7 @@ LINENUM pat_lines = pch_ptrn_lines() - fuzz; const char *ilineptr; const char *plineptr; - unsigned short plinelen; + int plinelen; for (iline = base + offset + fuzz; pline <= pat_lines; pline++, iline++) { ilineptr = ifetch(iline, offset >= 0); Index: usr.bin/patch/pch.c =================================================================== --- usr.bin/patch/pch.c (revision 311109) +++ usr.bin/patch/pch.c (working copy) @@ -56,7 +56,7 @@ static LINENUM p_context = 3; /* # of context lines */ static LINENUM p_input_line = 0; /* current line # from patch file */ static char **p_line = NULL;/* the text of the hunk */ -static unsigned short *p_len = NULL; /* length of each line */ +static int *p_len = NULL; /* length of each line */ static char *p_char = NULL; /* +, -, and ! */ static int hunkmax = INITHUNKMAX; /* size of above arrays to begin with */ static int p_indent; /* indent to patch */ @@ -136,7 +136,7 @@ if (p_line == NULL) p_line = malloc(hunkmax * sizeof(char *)); if (p_len == NULL) - p_len = malloc(hunkmax * sizeof(unsigned short)); + p_len = malloc(hunkmax * sizeof(int)); if (p_char == NULL) p_char = malloc(hunkmax * sizeof(char)); } @@ -153,7 +153,7 @@ fatal("Internal memory allocation error\n"); p_line = reallocf(p_line, new_hunkmax * sizeof(char *)); - p_len = reallocf(p_len, new_hunkmax * sizeof(unsigned short)); + p_len = reallocf(p_len, new_hunkmax * sizeof(int)); p_char = reallocf(p_char, new_hunkmax * sizeof(char)); if (p_line != NULL && p_len != NULL && p_char != NULL) { @@ -1210,7 +1210,7 @@ pch_swap(void) { char **tp_line; /* the text of the hunk */ - unsigned short *tp_len;/* length of each line */ + int *tp_len; /* length of each line */ char *tp_char; /* +, -, and ! */ LINENUM i; LINENUM n; @@ -1367,7 +1367,7 @@ /* * Return the length of a particular patch line. */ -unsigned short +int pch_line_len(LINENUM line) { return p_len[line]; Index: usr.bin/patch/pch.h =================================================================== --- usr.bin/patch/pch.h (revision 311109) +++ usr.bin/patch/pch.h (working copy) @@ -44,7 +44,7 @@ bool another_hunk(void); bool pch_swap(void); char *pfetch(LINENUM); -unsigned short pch_line_len(LINENUM); +int pch_line_len(LINENUM); LINENUM pch_first(void); LINENUM pch_ptrn_lines(void); LINENUM pch_newfirst(void); --------------840810EA8B3737957FA7B036--