Dr. Werner Fink 2010-04-06 13:30:12 +00:00 committed by Git OBS Bridge
parent 9edcabf533
commit 1c7f071deb
3 changed files with 18 additions and 144 deletions

View File

@ -14,145 +14,3 @@
}
#if 0
--- xmalloc.c
+++ xmalloc.c 2010-02-24 08:32:51.452626384 +0000
@@ -35,6 +35,11 @@
# include "ansi_stdlib.h"
#endif /* HAVE_STDLIB_H */
+/* Determine which kind of system this is. */
+#include <signal.h>
+extern int interrupt_immediately;
+extern int signal_is_trapped __P((int));
+
#include "error.h"
#include "bashintl.h"
@@ -94,6 +99,34 @@ allocerr (func, bytes)
#endif /* !HAVE_SBRK */
}
+static void
+block_signals (setp, osetp)
+ sigset_t *setp, *osetp;
+{
+#ifdef HAVE_POSIX_SIGNALS
+ sigfillset (setp);
+ sigemptyset (osetp);
+ sigprocmask (SIG_BLOCK, setp, osetp);
+#else
+# if defined (HAVE_BSD_SIGNALS)
+ *osetp = sigsetmask (-1);
+# endif
+#endif
+}
+
+static void
+unblock_signals (setp, osetp)
+ sigset_t *setp, *osetp;
+{
+#ifdef HAVE_POSIX_SIGNALS
+ sigprocmask (SIG_SETMASK, osetp, (sigset_t *)NULL);
+#else
+# if defined (HAVE_BSD_SIGNALS)
+ sigsetmask (*osetp);
+# endif
+#endif
+}
+
/* Return a pointer to free()able block of memory large enough
to hold BYTES number of bytes. If the memory cannot be allocated,
print an error message and abort. */
@@ -102,15 +135,28 @@ xmalloc (bytes)
size_t bytes;
{
PTR_T temp;
+ sigset_t set, oset;
+ int blocked_sigs;
#if defined (DEBUG)
if (bytes == 0)
internal_warning("xmalloc: size argument is 0");
#endif
+ /* Block all signals in case we are executed from a signal handler. */
+ blocked_sigs = 0;
+ if (interrupt_immediately || signal_is_trapped (SIGINT) || signal_is_trapped (SIGCHLD))
+ {
+ block_signals (&set, &oset);
+ blocked_sigs = 1;
+ }
+
FINDBRK();
temp = malloc (bytes);
+ if (blocked_sigs)
+ unblock_signals (&set, &oset);
+
if (temp == 0)
allocerr ("xmalloc", bytes);
@@ -123,15 +169,28 @@ xrealloc (pointer, bytes)
size_t bytes;
{
PTR_T temp;
+ sigset_t set, oset;
+ int blocked_sigs;
#if defined (DEBUG)
if (bytes == 0)
internal_warning("xrealloc: size argument is 0");
#endif
+ /* Block all signals in case we are executed from a signal handler. */
+ blocked_sigs = 0;
+ if (interrupt_immediately || signal_is_trapped (SIGINT) || signal_is_trapped (SIGCHLD))
+ {
+ block_signals (&set, &oset);
+ blocked_sigs = 1;
+ }
+
FINDBRK();
temp = pointer ? realloc (pointer, bytes) : malloc (bytes);
+ if (blocked_sigs)
+ unblock_signals (&set, &oset);
+
if (temp == 0)
allocerr ("xrealloc", bytes);
@@ -145,7 +204,22 @@ xfree (string)
PTR_T string;
{
if (string)
- free (string);
+ {
+ sigset_t set, oset;
+ int blocked_sigs = 0;
+
+ /* Block all signals in case we are executed from a signal handler. */
+ if (interrupt_immediately || signal_is_trapped (SIGINT) || signal_is_trapped (SIGCHLD))
+ {
+ block_signals (&set, &oset);
+ blocked_sigs = 1;
+ }
+
+ free (string);
+
+ if (blocked_sigs)
+ unblock_signals (&set, &oset);
+ }
}
#ifdef USING_BASH_MALLOC
--- builtins/read.def
+++ builtins/read.def 2010-03-02 16:24:59.070362886 +0000
@@ -387,6 +387,8 @@ read_builtin (list)
input_string. We want to run all the rest and use input_string,
so we have to remove it from the stack. */
remove_unwind_protect ();
+ interrupt_immediately--;
+ terminate_immediately = 0;
run_unwind_frame ("read_builtin");
input_string[i] = '\0'; /* make sure it's terminated */
retval = 128+SIGALRM;

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:04b5bbbf7fd0560da491e1a7610daea5ffc06a2df0b028fce25bd75d8d6c34e0
size 1506
oid sha256:73424968769484ed4ac52f07dbe882c9710faf8a348c0fffe57d64bbde8ad898
size 2814

View File

@ -1,3 +1,19 @@
-------------------------------------------------------------------
Tue Apr 6 15:27:24 CEST 2010 - werner@suse.de
- Update bash 4.1 to patch level 5 (related to bnc#522351)
* If command completion is attempted on a word with a quoted globbing
character (e.g., `*' or `?'), bash can reference a NULL pointer and
dump core.
* When running in Posix mode and executing a shell function without local
variables, bash will not propagate a variable in a special builtin's temporary
environment to have global scope.
* When the `read' builtin times out after the timeout specified with -t is
exceeded, it does not reset the flags that tell signal handlers to process
signals immediately instead of deferring their handling. This can result
in unsafe functions being called from signal handlers, which can cause bash
to hang or dump core.
-------------------------------------------------------------------
Tue Mar 9 15:34:05 CET 2010 - werner@suse.de