[gnu.utils.bug] Bug report and unofficial patch for patch v12u2

iverson@uunet.uu.net (Tim Iverson) (01/22/91)

This is an unofficial patch to patch 12u2 (the unified-diff-eating patch) to
overcome a problem when creating new files.

The Problem:	For the sake of brevity, let q(x) = 2^x*INITHUNKMAX-1.
		When patch tries to create a file with q(n) lines
		immediately after creating a q(m) line file and n < m,
		patch will halt with a segmentation violation.

		Actually, if you happen to test this on Tuesday with a
		sickle moon in the noontime sky, you may experience other
		bizzare problems due to memory corruption (but only if a
		dog barks while you run the test).

To Recreate:	Simply feed patch a file that contains two patches, one
		for a 499 line file diff'd against /dev/null, followed by
		one for a 124 line file diff'd against /dev/null.

To Fix:		Apply the enclosed patch.

- Tim Iverson
  iverson@xstor.com -/- uunet!xstor!iverson

BTW, this file also includes a patch to common.h to overcome a type clash
with a standard include file under SCO Unix.  It won't hurt you to leave it
there, but if SCO offends your delicate sensibilities, hacking it off may
yield a momentary pleasure.

#
################ patch starts here
##
Prereq: "12u2"
--- ../patch-2.0.12u2/patchlevel.h	Mon Jan  7 03:22:06 1991
+++ ./patchlevel.h	Mon Jan 21 18:12:33 1991
@@ -1,1 +1,1 @@
-#define PATCHLEVEL "12u2"
+#define PATCHLEVEL "12u3"
--- ../patch-2.0.12u2/pch.c	Mon Jan  7 03:19:12 1991
+++ ./pch.c	Mon Jan 21 18:09:50 1991
@@ -779,7 +779,7 @@
 	    malformed ();
 	if (!p_first && !p_ptrn_lines)
 	    p_first = 1;
-	p_max = p_ptrn_lines + p_repl_lines;
+	p_max = p_ptrn_lines + p_repl_lines + 1;
 	while (p_max >= hunkmax)
 	    grow_hunkmax();
 	p_max = hunkmax;
--- ../common.h	Mon Jan 21 23:06:40 1991
+++ ./common.h	Mon Jan 21 23:06:15 1991
@@ -153,9 +153,11 @@
 long atol();
 long lseek();
 char *mktemp();
+#ifndef M_UNIX
 #ifdef CHARSPRINTF
 char *sprintf();
 #else
 int sprintf();
+#endif
 #endif
 char *getenv();
##
################ patch ends here
#

iverson@uunet.uu.net (Tim Iverson) (01/22/91)

--text follows this line--
This is an unofficial patch to patch 12u2 (the unified-diff-eating patch) to
overcome a problem when creating new files.

The Problem:	For the sake of brevity, let q(x) = 2^x*INITHUNKMAX-1.
		When patch tries to create a file with q(n) lines
		immediately after creating a q(m) line file and n < m,
		patch will halt with a segmentation violation.

		Actually, if you happen to test this on Tuesday with a
		sickle moon in the noontime sky, you may experience other
		bizzare problems due to memory corruption (but only if a
		dog barks while you run the test).

To Recreate:	Simply feed patch a file that contains two patches, one
		for a 499 line file diff'd against /dev/null, followed by
		one for a 124 line file diff'd against /dev/null.

To Fix:		Apply the enclosed patch.

- Tim Iverson
  iverson@xstor.com -/- uunet!xstor!iverson

BTW, this file also includes a patch to common.h to overcome a type clash
with a standard include file under SCO Unix.  It won't hurt you to leave it
there, but if SCO offends your delicate sensibilities, hacking it off may
yield a momentary pleasure.

#
################ patch starts here
##
Prereq: "12u2"
--- ../patch-2.0.12u2/patchlevel.h	Mon Jan  7 03:22:06 1991
+++ ./patchlevel.h	Mon Jan 21 18:12:33 1991
@@ -1,1 +1,1 @@
-#define PATCHLEVEL "12u2"
+#define PATCHLEVEL "12u3"
--- ../patch-2.0.12u2/pch.c	Mon Jan  7 03:19:12 1991
+++ ./pch.c	Mon Jan 21 18:09:50 1991
@@ -779,7 +779,7 @@
 	    malformed ();
 	if (!p_first && !p_ptrn_lines)
 	    p_first = 1;
-	p_max = p_ptrn_lines + p_repl_lines;
+	p_max = p_ptrn_lines + p_repl_lines + 1;
 	while (p_max >= hunkmax)
 	    grow_hunkmax();
 	p_max = hunkmax;
--- ../common.h	Mon Jan 21 23:06:40 1991
+++ ./common.h	Mon Jan 21 23:06:15 1991
@@ -153,9 +153,11 @@
 long atol();
 long lseek();
 char *mktemp();
+#ifndef M_UNIX
 #ifdef CHARSPRINTF
 char *sprintf();
 #else
 int sprintf();
+#endif
 #endif
 char *getenv();
##
################ patch ends here
#