make: added patch from LFS to fix some bugs.

This commit is contained in:
Juan RP 2010-05-18 15:41:27 +02:00
parent 23409d37d7
commit 0d462ad48d
2 changed files with 128 additions and 0 deletions

View File

@ -0,0 +1,127 @@
Submitted By: Robert Connolly <robert at linuxfromscratch dot org> (ashes)
Date: 2010-02-24
Initial Package Version: 3.81
Upstream Status: From upstream
Origin: CVS
Description:
bug #27148: Use of strcpy on overlapping memory areas
http://savannah.gnu.org/bugs/?27148
http://cvs.savannah.gnu.org/viewvc/make/job.c?root=make&r1=1.194&r2=1.195
2009-08-01 Paul Smith <psmith@gnu.org>
* job.c (new_job): Use memmove() instead of strcpy() since both
pointers are in the same memory block. Fixes Savannah bug #27148.
Patch by Petr Machata.
bug #22010: The increased stack rlimit is inherited by the subprocesses to make.
http://savannah.gnu.org/bugs/?22010
http://cvs.savannah.gnu.org/viewvc/make/make.h?root=make&r1=1.132&r2=1.133&view=patch
http://cvs.savannah.gnu.org/viewvc/make/main.c?root=make&r1=1.228&r2=1.229&view=patch
http://cvs.savannah.gnu.org/viewvc/make/job.c?root=make&r1=1.191&r2=1.192&view=patch
2009-06-07 Paul Smith <psmith@gnu.org>
* make.h: Move SET_STACK_SIZE determination to make.h.
* main.c (main): New global variable, STACK_LIMIT, holds the
original stack limit when make was started.
* job.c (start_job_command): Reset the stack limit, if we changed it.
Fixes Savannah bug #22010.
--- job.c 2006-03-20 03:03:04.000000000 +0000
+++ job.c 2010-02-24 09:41:51.000000000 +0000
@@ -1275,6 +1275,12 @@
if (job_rfd >= 0)
close (job_rfd);
+#ifdef SET_STACK_SIZE
+ /* Reset limits, if necessary. */
+ if (stack_limit.rlim_cur)
+ setrlimit (RLIMIT_STACK, &stack_limit);
+#endif
+
child_execute_job (child->good_stdin ? 0 : bad_stdin, 1,
argv, child->environment);
}
@@ -1594,7 +1600,7 @@
/* There are no more references in this line to worry about.
Copy the remaining uninteresting text to the output. */
if (out != in)
- strcpy (out, in);
+ memmove (out, in, strlen (in) + 1);
/* Finally, expand the line. */
lines[i] = allocated_variable_expand_for_file (cmds->command_lines[i],
@@ -2237,7 +2243,7 @@
"for", "case", "if", ":", ".", "break",
"continue", "export", "read", "readonly",
"shift", "times", "trap", "switch", "unset",
- 0 };
+ "ulimit", 0 };
char *sh_chars;
char **sh_cmds;
--- main.c 2006-03-20 02:36:37.000000000 +0000
+++ main.c 2010-02-24 09:49:30.000000000 +0000
@@ -44,14 +44,6 @@
# include <fcntl.h>
#endif
-#if defined(HAVE_SYS_RESOURCE_H) && defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT)
-# define SET_STACK_SIZE
-#endif
-
-#ifdef SET_STACK_SIZE
-# include <sys/resource.h>
-#endif
-
#ifdef _AMIGA
int __stack = 20000; /* Make sure we have 20K of stack space */
#endif
@@ -213,6 +205,13 @@
static struct stringlist *makefiles = 0;
+/* Size of the stack when we started. */
+
+#ifdef SET_STACK_SIZE
+struct rlimit stack_limit;
+#endif
+
+
/* Number of job slots (commands that can be run at once). */
unsigned int job_slots = 1;
@@ -919,11 +918,15 @@
struct rlimit rlim;
/* Set the stack limit huge so that alloca does not fail. */
- if (getrlimit (RLIMIT_STACK, &rlim) == 0)
+ if (getrlimit (RLIMIT_STACK, &rlim) == 0
+ && rlim.rlim_cur > 0 && rlim.rlim_cur < rlim.rlim_max)
{
+ stack_limit = rlim;
rlim.rlim_cur = rlim.rlim_max;
setrlimit (RLIMIT_STACK, &rlim);
}
+ else
+ stack_limit.rlim_cur = 0;
}
#endif
--- make.h 2006-02-15 23:54:43.000000000 +0000
+++ make.h 2010-02-24 09:46:47.000000000 +0000
@@ -378,6 +378,14 @@
extern int unixy_shell;
#endif /* WINDOWS32 */
+#if defined(HAVE_SYS_RESOURCE_H) && defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT)
+# define SET_STACK_SIZE
+#endif
+#ifdef SET_STACK_SIZE
+# include <sys/resource.h>
+struct rlimit stack_limit;
+#endif
+
struct floc
{
const char *filenm;

View File

@ -1,6 +1,7 @@
# Template build file for 'make' # Template build file for 'make'
pkgname=make pkgname=make
version=3.81 version=3.81
revision=1
distfiles="http://ftp.gnu.org/pub/gnu/make/$pkgname-$version.tar.bz2" distfiles="http://ftp.gnu.org/pub/gnu/make/$pkgname-$version.tar.bz2"
build_style=gnu_configure build_style=gnu_configure
short_desc="The GNU make system" short_desc="The GNU make system"