Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 18 Jan 2018 21:46:42 +0000 (UTC)
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r328147 - stable/11/usr.bin/patch
Message-ID:  <201801182146.w0ILkgoU015084@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kevans
Date: Thu Jan 18 21:46:42 2018
New Revision: 328147
URL: https://svnweb.freebsd.org/changeset/base/328147

Log:
  MFC r324431: patch(1): Don't overrun line buffer in some cases
  
  Patches like file.txt attached to PR 190195 with a final line formed
  like ">(EOL)" could cause a copy past the end of the current line buffer. In
  the case of PR 191641, this caused a duplicate line to be copied into the
  resulting file.
  
  Instead of running past the end, treat it as if it were a blank line.
  
  PR:		191641

Modified:
  stable/11/usr.bin/patch/pch.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/usr.bin/patch/pch.c
==============================================================================
--- stable/11/usr.bin/patch/pch.c	Thu Jan 18 21:46:09 2018	(r328146)
+++ stable/11/usr.bin/patch/pch.c	Thu Jan 18 21:46:42 2018	(r328147)
@@ -1125,7 +1125,12 @@ hunk_done:
 			if (*buf != '>')
 				fatal("> expected at line %ld of patch\n",
 				    p_input_line);
-			p_line[i] = savestr(buf + 2);
+			/* Don't overrun if we don't have enough line */
+			if (len > 2)
+				p_line[i] = savestr(buf + 2);
+			else
+				p_line[i] = savestr("");
+
 			if (out_of_mem) {
 				p_end = i - 1;
 				return false;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201801182146.w0ILkgoU015084>