mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-06-30 00:49:57 +02:00
fix longjmp error when timing null command in posix mode; unset exit trap in subshells before checking for pending fatal signal; changes for gcc sometimes-uninitialized warning
This commit is contained in:
@@ -12282,3 +12282,32 @@ subst.c
|
||||
when they are expanded in a context that will not perform word
|
||||
splitting
|
||||
Report by Emanuele Torre <torreemanuele6@gmail.com>
|
||||
|
||||
execute_cmd.c
|
||||
- time_command: make sure to initialize CODE in the posix and null
|
||||
command case so we don't longjmp to nowhere
|
||||
Report and patch from Grisha Levit <grishalevit@gmail.com>
|
||||
|
||||
pathexp.c
|
||||
- globsort_sortarray: if the sort type is unknown, default sortfunc
|
||||
to globsort_namecmp
|
||||
|
||||
error.h
|
||||
- programming_error: add `noreturn' attribute
|
||||
|
||||
11/25
|
||||
-----
|
||||
variables.c
|
||||
- get_bash_name: use sh_realpath instead of sh_canonpath; less code
|
||||
Modification of change from 11/18
|
||||
|
||||
12/1
|
||||
----
|
||||
trap.c, trap.h
|
||||
- clear_exit_trap: new function to unset the exit trap and clear out
|
||||
the trap string
|
||||
|
||||
execute_cmd.c
|
||||
- execute_in_subshell: clear the exit trap before checking for a
|
||||
pending fatal signal
|
||||
From https://savannah.gnu.org/bugs/?67745
|
||||
|
||||
+1
-1
@@ -176,6 +176,7 @@ extern int errno;
|
||||
|
||||
#define SKIP1 "#'-+ 0"
|
||||
#define LENMODS "hjlLtz"
|
||||
#define DIGITS "0123456789"
|
||||
|
||||
#ifndef TIMELEN_MAX
|
||||
# define TIMELEN_MAX 128
|
||||
@@ -246,7 +247,6 @@ static size_t vblen;
|
||||
static char **narg_argv;
|
||||
static int narg_argc;
|
||||
static int narg_maxind;
|
||||
static int narg_curind;
|
||||
|
||||
static intmax_t tw;
|
||||
|
||||
|
||||
+1
-1
@@ -9068,7 +9068,7 @@ The character whose ASCII code is the octal value @var{nnn}.
|
||||
A backslash.
|
||||
@item \[
|
||||
Begin a sequence of non-printing characters.
|
||||
Thiss could be used to
|
||||
This could be used to
|
||||
embed a terminal control sequence into the prompt.
|
||||
@item \]
|
||||
End a sequence of non-printing characters.
|
||||
|
||||
@@ -30,7 +30,7 @@ extern char *get_name_for_error (void);
|
||||
extern void file_error (const char *);
|
||||
|
||||
/* Report a programmer's error, and abort. Pass REASON, and ARG1 ... ARG5. */
|
||||
extern void programming_error (const char *, ...) __attribute__((__format__ (printf, 1, 2)));
|
||||
extern void programming_error (const char *, ...) __attribute__((__format__ (printf, 1, 2))) __attribute__((__noreturn__));;
|
||||
|
||||
/* General error reporting. Pass FORMAT and ARG1 ... ARG5. */
|
||||
extern void report_error (const char *, ...) __attribute__((__format__ (printf, 1, 2)));
|
||||
|
||||
@@ -1489,6 +1489,8 @@ time_command (COMMAND *command, int asynchronous, int pipe_in, int pipe_out, str
|
||||
rsf = usf = ssf = 0;
|
||||
cpu = 0;
|
||||
|
||||
code = 0;
|
||||
|
||||
old_subshell = subshell_environment;
|
||||
posix_time = command && (command->flags & CMD_TIME_POSIX);
|
||||
nullcmd = (command == 0) || (command->type == cm_simple && command->value.Simple->words == 0 && command->value.Simple->redirects == 0);
|
||||
@@ -1686,6 +1688,9 @@ execute_in_subshell (COMMAND *command, int asynchronous, int pipe_in, int pipe_o
|
||||
subshell_environment |= SUBSHELL_COPROC;
|
||||
}
|
||||
|
||||
/* clear the exit trap before checking for fatal signals */
|
||||
clear_exit_trap ();
|
||||
|
||||
QUIT;
|
||||
CHECK_TERMSIG;
|
||||
|
||||
|
||||
@@ -2317,7 +2317,7 @@ make_child (char *command, int flags)
|
||||
break;
|
||||
forksleep <<= 1;
|
||||
|
||||
if (interrupt_state)
|
||||
if (interrupt_state) /* XXX - and terminating_signal? */
|
||||
break;
|
||||
sigprocmask (SIG_SETMASK, &set, (sigset_t *)NULL);
|
||||
}
|
||||
|
||||
@@ -904,6 +904,7 @@ globsort_sortarray (struct globsort_t *garray, size_t len)
|
||||
break;
|
||||
default:
|
||||
internal_error (_("invalid glob sort type"));
|
||||
sortfunc = (QSFUNC *)globsort_namecmp;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* trap.c -- Not the trap command, but useful functions for manipulating
|
||||
those objects. The trap command is in builtins/trap.def. */
|
||||
|
||||
/* Copyright (C) 1987-2024 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2025 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -1102,6 +1102,18 @@ run_trap_cleanup (int sig)
|
||||
sigmodes[sig] &= ~(SIG_INPROGRESS|SIG_CHANGED);
|
||||
}
|
||||
|
||||
void
|
||||
clear_exit_trap ()
|
||||
{
|
||||
if (sigmodes[EXIT_TRAP] & SIG_TRAPPED)
|
||||
{
|
||||
sigmodes[EXIT_TRAP] &= ~SIG_TRAPPED; /* XXX - SIG_INPROGRESS? */
|
||||
free_trap_command (EXIT_TRAP);
|
||||
trap_list[EXIT_TRAP] = (char *)NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#define RECURSIVE_SIG(s) (SPECIAL_TRAP(s) == 0)
|
||||
|
||||
/* Run a trap command for SIG. SIG is one of the signals the shell treats
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* trap.h -- data structures used in the trap mechanism. */
|
||||
|
||||
/* Copyright (C) 1993-2023 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1993-2025 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -91,6 +91,8 @@ extern void set_signal (int, const char *);
|
||||
|
||||
extern void restore_default_signal (int);
|
||||
extern void ignore_signal (int);
|
||||
|
||||
extern void clear_exit_trap (void);
|
||||
extern int run_exit_trap (void);
|
||||
extern void run_trap_cleanup (int);
|
||||
extern int run_debug_trap (void);
|
||||
|
||||
+2
-15
@@ -820,24 +820,11 @@ get_bash_name (void)
|
||||
tname = make_absolute (shell_name, get_string_value ("PWD"));
|
||||
if (*shell_name == '.')
|
||||
{
|
||||
char *x, *fp;
|
||||
|
||||
x = strrchr (tname, '/');
|
||||
*x = 0;
|
||||
name = sh_canonpath (tname, PATH_CHECKDOTDOT|PATH_CHECKEXISTS);
|
||||
*x++ = '/';
|
||||
name = sh_realpath (tname, 0);
|
||||
if (name == 0)
|
||||
name = tname;
|
||||
else
|
||||
{
|
||||
fp = sh_makepath (name, x, 0);
|
||||
free (tname);
|
||||
if (fp)
|
||||
{
|
||||
free (name);
|
||||
name = fp;
|
||||
}
|
||||
}
|
||||
free (tname);
|
||||
}
|
||||
else
|
||||
name = tname;
|
||||
|
||||
Reference in New Issue
Block a user