svn commit: r328147 - stable/11/usr.bin/patch

Kyle Evans kevans at FreeBSD.org
Thu Jan 18 21:46:43 UTC 2018


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;


More information about the svn-src-stable-11 mailing list