]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
fix longjmp error when timing null command in posix mode; unset exit trap in subshell...
authorChet Ramey <chet.ramey@case.edu>
Tue, 2 Dec 2025 22:15:44 +0000 (17:15 -0500)
committerChet Ramey <chet.ramey@case.edu>
Tue, 2 Dec 2025 22:15:44 +0000 (17:15 -0500)
CWRU/CWRU.chlog
builtins/printf.def
doc/bashref.texi
error.h
execute_cmd.c
jobs.c
pathexp.c
trap.c
trap.h
variables.c

index 8580314bf363276dbc5ad3d4c271450401692c64..65f4c95b01cf7aeb27756c36877546f5d145738a 100644 (file)
@@ -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
index 2de73b54aaa091af040e0fe0993e37ee978a8bea..2bb705811bbe1b240dfc098ed5b5a4ab1878e694 100644 (file)
@@ -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;
 
index 7012cf6c55e2caa6d31dd125c61b215cb7dff55d..705d259ba5dae76ba848c8eafaa8f725578c58c2 100644 (file)
@@ -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.
diff --git a/error.h b/error.h
index db0972bc87eb9ce60eff9227dbfd9ef6bb307bec..6254fee1a318fda0d3a85cc19d255cf1346a9825 100644 (file)
--- a/error.h
+++ b/error.h
@@ -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)));
index a0b66015b6c810108d18ce19182c7c25f813a8c3..a6d4a096b65d0b0d7816fdd94e1155a3b3c85d39 100644 (file)
@@ -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;
 
diff --git a/jobs.c b/jobs.c
index 07f8ca7a7625ead72642aeb0aaaf1016144e4a3a..d8f7aae4771f104c788ad3761615de432f403ad2 100644 (file)
--- a/jobs.c
+++ b/jobs.c
@@ -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);
     }
index 1692e054fdd57929c458fae764499e7b0a2a8b0f..87c49bf314c7e8df3a42aef4f0e3ac3bd135372a 100644 (file)
--- a/pathexp.c
+++ b/pathexp.c
@@ -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;
     }
 
diff --git a/trap.c b/trap.c
index ea103f58cf22aa9744faebe37ed7fddfe91cd01a..edac55402f3d9fc95444156ab7000101d594c323 100644 (file)
--- a/trap.c
+++ b/trap.c
@@ -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
diff --git a/trap.h b/trap.h
index 82a3c65106a0b97aa65e3aa31c96f14263033cc4..093beab2b62761cf116c0bcbd93291b649e06005 100644 (file)
--- a/trap.h
+++ b/trap.h
@@ -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);
index 00a73da842391c006c728f4887925ac913f2ba90..5ef53a928965335c70c5fadc4fb7a95ca9e4f678 100644 (file)
@@ -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;