Compare commits

...

10 Commits

Author SHA1 Message Date
openeuler-ci-bot
65fc49a65a
!117 del doesn't exist PATH dirs in bashrc
From: @wangyuhang27 
Reviewed-by: @licunlong 
Signed-off-by: @licunlong
2023-12-07 12:45:09 +00:00
wangyuhang
133e8ff2a0 del doesn't exist PATH dirs in bashrc 2023-12-07 14:55:55 +08:00
openeuler-ci-bot
f9aa6c3320
!115 [sync] PR-114: sync patches from bash community
From: @openeuler-sync-bot 
Reviewed-by: @openeuler-basic 
Signed-off-by: @openeuler-basic
2023-12-04 14:07:51 +00:00
hongjinghao
325d73e107 sync patches from bash community
(cherry picked from commit 6c6f6a563bba99de4af22de10db699ceb195a3d2)
2023-12-04 20:47:42 +08:00
openeuler-ci-bot
906569afa6
!82 sync patches from bash community
From: @wangyuhang27 
Reviewed-by: @openeuler-basic 
Signed-off-by: @openeuler-basic
2023-04-23 09:28:06 +00:00
wangyuhang
4aefbcee9f sync patches from bash community 2023-04-23 15:11:34 +08:00
openeuler-ci-bot
f7d651b0b0
!63 fix bugfix-Forbidden-non-root-user-to-clear-history.patch
From: @panxh_purple 
Reviewed-by: @overweight 
Signed-off-by: @overweight
2022-08-13 01:45:35 +00:00
panxiaohe
f0c0f5c502 fix bugfix-Forbidden-non-root-user-to-clear-history.patch 2022-08-12 10:00:17 +08:00
openeuler-ci-bot
dce4e3f730
!42 【轻量级PR】修正changelog中的错误日期
From: @konglidong 
Reviewed-by: @overweight 
Signed-off-by: @overweight
2022-05-06 08:03:34 +00:00
konglidong
d999102b9f modify bogus date in %changelog 2022-05-06 15:32:52 +08:00
8 changed files with 673 additions and 14 deletions

View File

@ -0,0 +1,184 @@
From 15409324f1974d41c183904ad575da7188058c1c Mon Sep 17 00:00:00 2001
From: Chet Ramey <chet.ramey@case.edu>
Date: Wed, 17 Nov 2021 16:47:24 -0500
Subject: [PATCH] Bash-5.1 patch 12: fix race condition with child processes
and resetting trapped signals
Conflict:Adapt Code Context
Reference:https://git.savannah.gnu.org/cgit/bash.git/commit/?id=15409324f1974d41c183904ad575da7188058c1c
---
command.h | 1 +
execute_cmd.c | 8 +++++++-
jobs.c | 2 ++
nojobs.c | 2 ++
sig.c | 10 +++++++++-
subst.c | 2 ++
trap.c | 26 ++++++++++++++++++++++++++
7 files changed, 49 insertions(+), 2 deletions(-)
diff --git a/command.h b/command.h
index 914198f9..b8477528 100644
--- a/command.h
+++ b/command.h
@@ -124,6 +124,7 @@ enum command_type { cm_for, cm_case, cm_while, cm_if, cm_simple, cm_select,
#define SUBSHELL_PROCSUB 0x20 /* subshell caused by <(command) or >(command) */
#define SUBSHELL_COPROC 0x40 /* subshell from a coproc pipeline */
#define SUBSHELL_RESETTRAP 0x80 /* subshell needs to reset trap strings on first call to trap */
+#define SUBSHELL_IGNTRAP 0x100 /* subshell should reset trapped signals from trap_handler */
/* A structure which represents a word. */
typedef struct word_desc {
diff --git a/execute_cmd.c b/execute_cmd.c
index 90129e06..425679a2 100644
--- a/execute_cmd.c
+++ b/execute_cmd.c
@@ -1547,6 +1547,9 @@ execute_in_subshell (command, asynchronous, pipe_in, pipe_out, fds_to_close)
trap strings if we run trap to change a signal disposition. */
reset_signal_handlers ();
subshell_environment |= SUBSHELL_RESETTRAP;
+ /* Note that signal handlers have been reset, so we should no longer
+ reset the handler and resend trapped signals to ourselves. */
+ subshell_environment &= ~SUBSHELL_IGNTRAP;
#if 0 /* TAG:bash-5.1 */
/* We are in a subshell, so forget that we are running a trap handler or
that the signal handler has changed (we haven't changed it!) */
@@ -4248,7 +4326,8 @@ execute_simple_command (simple_command, pipe_in, pipe_out, async, fds_to_close)
already_forked = 1;
simple_command->flags |= CMD_NO_FORK;
- subshell_environment = SUBSHELL_FORK; /* XXX */
+ /* We redo some of what make_child() does with SUBSHELL_IGNTRAP */
+ subshell_environment = SUBSHELL_FORK|SUBSHELL_IGNTRAP; /* XXX */
if (pipe_in != NO_PIPE || pipe_out != NO_PIPE)
subshell_environment |= SUBSHELL_PIPE;
if (async)
@@ -4574,6 +4578,7 @@ run_builtin:
trap strings if we run trap to change a signal disposition. */
reset_signal_handlers ();
subshell_environment |= SUBSHELL_RESETTRAP;
+ subshell_environment &= ~SUBSHELL_IGNTRAP;
if (async)
{
@@ -5514,6 +5519,7 @@ execute_disk_command (words, redirects, command_line, pipe_in, pipe_out,
reset_terminating_signals (); /* XXX */
/* Cancel traps, in trap.c. */
restore_original_signals ();
+ subshell_environment &= ~SUBSHELL_IGNTRAP;
CHECK_SIGTERM;
diff --git a/jobs.c b/jobs.c
index a581f305..7c3b6e83 100644
--- a/jobs.c
+++ b/jobs.c
@@ -2217,6 +2217,8 @@ make_child (command, flags)
signals to the default state for a new process. */
pid_t mypid;
+ subshell_environment |= SUBSHELL_IGNTRAP;
+
/* If this ends up being changed to modify or use `command' in the
child process, go back and change callers who free `command' in
the child process when this returns. */
diff --git a/nojobs.c b/nojobs.c
index c5fc83d9..f2563ca0 100644
--- a/nojobs.c
+++ b/nojobs.c
@@ -575,6 +575,8 @@ make_child (command, flags)
last_asynchronous_pid = getpid ();
#endif
+ subshell_environment |= SUBSHELL_IGNTRAP;
+
default_tty_job_signals ();
}
else
diff --git a/sig.c b/sig.c
index 6964d862..e6537d26 100644
--- a/sig.c
+++ b/sig.c
@@ -55,7 +55,8 @@
# include "bashhist.h"
#endif
-extern void initialize_siglist ();
+extern void initialize_siglist PARAMS((void));
+extern void set_original_signal PARAMS((int, SigHandler *));
#if !defined (JOB_CONTROL)
extern void initialize_job_signals __P((void));
@@ -255,6 +256,13 @@ initialize_terminating_signals ()
sigaction (XSIG (i), &act, &oact);
XHANDLER(i) = oact.sa_handler;
XSAFLAGS(i) = oact.sa_flags;
+
+#if 0
+ set_original_signal (XSIG(i), XHANDLER(i)); /* optimization */
+#else
+ set_original_signal (XSIG(i), act.sa_handler); /* optimization */
+#endif
+
/* Don't do anything with signals that are ignored at shell entry
if the shell is not interactive. */
/* XXX - should we do this for interactive shells, too? */
diff --git a/subst.c b/subst.c
index 462752de..327de083 100644
--- a/subst.c
+++ b/subst.c
@@ -5951,6 +5951,7 @@ process_substitute (string, open_for_read_in_child)
free_pushed_string_input ();
/* Cancel traps, in trap.c. */
restore_original_signals (); /* XXX - what about special builtins? bash-4.2 */
+ subshell_environment &= ~SUBSHELL_IGNTRAP;
QUIT; /* catch any interrupts we got post-fork */
setup_async_signals ();
subshell_environment |= SUBSHELL_COMSUB|SUBSHELL_PROCSUB;
@@ -6382,6 +6383,7 @@ command_substitute (string, quoted, flags)
}
QUIT; /* catch any interrupts we got post-fork */
subshell_environment |= SUBSHELL_RESETTRAP;
+ subshell_environment &= ~SUBSHELL_IGNTRAP;
}
#if defined (JOB_CONTROL)
diff --git a/trap.c b/trap.c
index c7f8ded5..1b27fb3a 100644
--- a/trap.c
+++ b/trap.c
@@ -481,6 +481,32 @@ trap_handler (sig)
SIGRETURN (0);
}
+ /* This means we're in a subshell, but have not yet reset the handler for
+ trapped signals. We're not supposed to execute the trap in this situation;
+ we should restore the original signal and resend the signal to ourselves
+ to preserve the Posix "signal traps that are not being ignored shall be
+ set to the default action" semantics. */
+ if ((subshell_environment & SUBSHELL_IGNTRAP) && trap_list[sig] != (char *)IGNORE_SIG)
+ {
+ sigset_t mask;
+
+ /* Paranoia */
+ if (original_signals[sig] == IMPOSSIBLE_TRAP_HANDLER)
+ original_signals[sig] = SIG_DFL;
+
+ restore_signal (sig);
+
+ /* Make sure we let the signal we just caught through */
+ sigemptyset (&mask);
+ sigprocmask (SIG_SETMASK, (sigset_t *)NULL, &mask);
+ sigdelset (&mask, sig);
+ sigprocmask (SIG_SETMASK, &mask, (sigset_t *)NULL);
+
+ kill (getpid (), sig);
+
+ SIGRETURN (0);
+ }
+
if ((sig >= NSIG) ||
(trap_list[sig] == (char *)DEFAULT_SIG) ||
(trap_list[sig] == (char *)IGNORE_SIG))
--
2.33.0

View File

@ -0,0 +1,42 @@
From 9439ce094c9aa7557a9d53ac7b412a23aa66e36b Mon Sep 17 00:00:00 2001
From: Chet Ramey <chet.ramey@case.edu>
Date: Tue, 4 Jan 2022 17:03:45 -0500
Subject: [PATCH] Bash-5.1 patch 16: fix interpretation of multiple instances
of ! in [[ conditional commands
Conflict:NA
Reference:https://git.savannah.gnu.org/cgit/bash.git/commit/?id=9439ce094c9aa7557a9d53ac7b412a23aa66e36b
---
parse.y | 2 +-
y.tab.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/parse.y b/parse.y
index f25575b5..f4168c7c 100644
--- a/parse.y
+++ b/parse.y
@@ -4796,7 +4796,7 @@ cond_term ()
dispose_word (yylval.word); /* not needed */
term = cond_term ();
if (term)
- term->flags |= CMD_INVERT_RETURN;
+ term->flags ^= CMD_INVERT_RETURN;
}
else if (tok == WORD && yylval.word->word[0] == '-' && yylval.word->word[1] && yylval.word->word[2] == 0 && test_unop (yylval.word->word))
{
diff --git a/y.tab.c b/y.tab.c
index c11d7aaa..78b38250 100644
--- a/y.tab.c
+++ b/y.tab.c
@@ -7090,7 +7090,7 @@ cond_term ()
dispose_word (yylval.word); /* not needed */
term = cond_term ();
if (term)
- term->flags |= CMD_INVERT_RETURN;
+ term->flags ^= CMD_INVERT_RETURN;
}
else if (tok == WORD && yylval.word->word[0] == '-' && yylval.word->word[1] && yylval.word->word[2] == 0 && test_unop (yylval.word->word))
{
--
2.33.0

View File

@ -0,0 +1,78 @@
From 7f7ee0e9c6766ff5d3de542d03c59590c4a5a44a Mon Sep 17 00:00:00 2001
From: Chet Ramey <chet.ramey@case.edu>
Date: Mon, 17 Jul 2023 17:35:59 -0400
Subject: [PATCH] fix for leak when completing command word with glob pattern
that matches multiple files; preserve export attribute when unsetting local
variable in case it is reset; fix for using nl_langinfo when performing
charset conversions
---
bashline.c | 6 +++++-
lib/sh/unicode.c | 6 +++++-
variables.c | 6 ++++++
3 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/bashline.c b/bashline.c
index c85b05b..2e0c0c7 100644
--- a/bashline.c
+++ b/bashline.c
@@ -2203,7 +2203,11 @@ globword:
local_index = 0;
if (glob_matches[1] && rl_completion_type == TAB) /* multiple matches are bad */
- return ((char *)NULL);
+ {
+ strvec_dispose (glob_matches);
+ glob_matches = (char **)NULL;
+ return ((char *)NULL);
+ }
}
while (val = glob_matches[local_index++])
diff --git a/lib/sh/unicode.c b/lib/sh/unicode.c
index d781353..9e3c9da 100644
--- a/lib/sh/unicode.c
+++ b/lib/sh/unicode.c
@@ -35,6 +35,10 @@
# include <iconv.h>
#endif
+#if HAVE_LANGINFO_CODESET
+# include <langinfo.h>
+#endif
+
#include <xmalloc.h>
#ifndef USHORT_MAX
@@ -277,7 +281,7 @@ u32cconv (c, s)
{
#if HAVE_LOCALE_CHARSET
charset = locale_charset ();
-#elif HAVE_NL_LANGINFO
+#elif HAVE_LANGINFO_CODESET
charset = nl_langinfo (CODESET);
#else
charset = stub_charset ();
diff --git a/variables.c b/variables.c
index 1a0c2c4..f08575a 100644
--- a/variables.c
+++ b/variables.c
@@ -4016,10 +4016,16 @@ makunbound (name, vc)
FREE (nameref_cell (old_var));
else
FREE (value_cell (old_var));
+#if 0
/* Reset the attributes. Preserve the export attribute if the variable
came from a temporary environment. Make sure it stays local, and
make it invisible. */
old_var->attributes = (exported_p (old_var) && tempvar_p (old_var)) ? att_exported : 0;
+#else /* TAG:bash-5.3 look at this again */
+ /* Reset the attributes, but preserve the export attribute.
+ Make sure it stays local, and make it invisible. */
+ old_var->attributes = exported_p (old_var) ? att_exported : 0;
+#endif
VSETATTR (old_var, att_local);
VSETATTR (old_var, att_invisible);
var_setvalue (old_var, (char *)NULL);
--
2.33.0

View File

@ -0,0 +1,265 @@
From 4e4cebb6dcf4522243b5b9e87918789aea8f73a1 Mon Sep 17 00:00:00 2001
From: Chet Ramey <chet.ramey@case.edu>
Date: Tue, 20 Jun 2023 11:10:39 -0400
Subject: [PATCH] fix for nofork comsub command printing; fix for crash caused
by tempvar assignment converted to an array in a function
---
arrayfunc.c | 13 ++++++++++
arrayfunc.h | 2 ++
builtins/declare.def | 13 +++++++---
print_cmd.c | 12 +++++----
shell.h | 2 ++
subst.h | 1 +
variables.c | 59 ++++++++++++++++++++++++++++++--------------
7 files changed, 74 insertions(+), 28 deletions(-)
diff --git a/arrayfunc.c b/arrayfunc.c
index e4ae34d..44b051e 100644
--- a/arrayfunc.c
+++ b/arrayfunc.c
@@ -137,6 +137,19 @@ convert_var_to_assoc (var)
return var;
}
+/* Copy the array (ARRAY *) or assoc (HASH_TABLE *) from variable V1 to V2,
+ and return V2. */
+SHELL_VAR *
+arrayvar_copyval (SHELL_VAR *v1, SHELL_VAR *v2)
+{
+ FREE (value_cell (v2));
+ if (array_p (v1))
+ var_setarray (v2, array_copy (array_cell (v1)));
+ else if (assoc_p (v1))
+ var_setassoc (v2, assoc_copy (assoc_cell (v1)));
+ return v2;
+}
+
char *
make_array_variable_value (entry, ind, key, value, flags)
SHELL_VAR *entry;
diff --git a/arrayfunc.h b/arrayfunc.h
index cd51ee0..27d8579 100644
--- a/arrayfunc.h
+++ b/arrayfunc.h
@@ -47,6 +47,8 @@ extern int array_expand_once;
extern SHELL_VAR *convert_var_to_array __P((SHELL_VAR *));
extern SHELL_VAR *convert_var_to_assoc __P((SHELL_VAR *));
+extern SHELL_VAR *arrayvar_copyval (SHELL_VAR *, SHELL_VAR *);
+
extern char *make_array_variable_value __P((SHELL_VAR *, arrayind_t, char *, char *, int));
extern SHELL_VAR *bind_array_variable __P((char *, arrayind_t, char *, int));
diff --git a/builtins/declare.def b/builtins/declare.def
index 7eac6f5..97c8efc 100644
--- a/builtins/declare.def
+++ b/builtins/declare.def
@@ -952,20 +952,25 @@ restart_new_var_name:
if ((flags_on & (att_exported|att_readonly)) && tempvar_p (var))
{
SHELL_VAR *tv;
- char *tvalue;
tv = find_tempenv_variable (var->name);
if (tv)
{
- tvalue = var_isset (var) ? savestring (value_cell (var)) : savestring ("");
- tv = bind_variable (var->name, tvalue, 0);
+ /* We don't bother with modifying the temporary env because
+ we're already using it. */
+ tv = bind_variable (name_cell (var), value_cell (var), ASS_NOTEMPENV);
if (tv)
{
+#if defined (ARRAY_VARS)
+ /* copy array value if array variable */
+ if ((array_p (var) || assoc_p (var)))
+ arrayvar_copyval (var, tv);
+#endif
+ /* then copy attributes */
tv->attributes |= var->attributes & ~att_tempvar;
if (tv->context > 0)
VSETATTR (tv, att_propagate);
}
- free (tvalue);
}
VSETATTR (var, att_propagate);
}
diff --git a/print_cmd.c b/print_cmd.c
index 9aa6557..6607993 100644
--- a/print_cmd.c
+++ b/print_cmd.c
@@ -666,7 +666,7 @@ print_group_command (group_command)
group_command_nesting++;
cprintf ("{ ");
- if (inside_function_def == 0)
+ if (inside_function_def == 0 /* && pretty_print_mode == 0 */)
skip_this_indent++;
else
{
@@ -680,7 +680,7 @@ print_group_command (group_command)
make_command_string_internal (group_command->command);
PRINT_DEFERRED_HEREDOCS ("");
- if (inside_function_def)
+ if (inside_function_def /* || pretty_print_mode */)
{
cprintf ("\n");
indentation -= indentation_amount;
@@ -1459,9 +1459,11 @@ indent (amount)
static void
semicolon ()
{
- if (command_string_index > 0 &&
- (the_printed_command[command_string_index - 1] == '&' ||
- the_printed_command[command_string_index - 1] == '\n'))
+ if ((command_string_index > 0 &&
+ the_printed_command[command_string_index - 1] == '\n') ||
+ (command_string_index > 1 &&
+ the_printed_command[command_string_index - 1] == '&' &&
+ the_printed_command[command_string_index - 2] == ' '))
return;
cprintf (";");
}
diff --git a/shell.h b/shell.h
index 8072605..fef9347 100644
--- a/shell.h
+++ b/shell.h
@@ -106,6 +106,8 @@ extern int indirection_level;
extern int shell_compatibility_level;
extern int running_under_emacs;
+extern int pretty_print_mode;
+
extern int posixly_correct;
extern int no_line_editing;
diff --git a/subst.h b/subst.h
index faf831b..b161c3c 100644
--- a/subst.h
+++ b/subst.h
@@ -54,6 +54,7 @@
#define ASS_NOEXPAND 0x0080 /* don't expand associative array subscripts */
#define ASS_NOEVAL 0x0100 /* don't evaluate value as expression */
#define ASS_NOLONGJMP 0x0200 /* don't longjmp on fatal assignment error */
+#define ASS_NOTEMPENV 0x2000 /* don't assign into temporary environment */
/* Flags for the string extraction functions. */
#define SX_NOALLOC 0x0001 /* just skip; don't return substring */
diff --git a/variables.c b/variables.c
index 7abd778..21be2cd 100644
--- a/variables.c
+++ b/variables.c
@@ -259,6 +259,8 @@ static SHELL_VAR *new_shell_variable __P((const char *));
static SHELL_VAR *make_new_variable __P((const char *, HASH_TABLE *));
static SHELL_VAR *bind_variable_internal __P((const char *, char *, HASH_TABLE *, int, int));
+static void init_shell_variable (SHELL_VAR *);
+
static void dispose_variable_value __P((SHELL_VAR *));
static void free_variable_hash_data __P((PTR_T));
@@ -2683,6 +2685,21 @@ make_local_variable (name, flags)
new_var = make_new_variable (name, vc->table);
else
{
+#if 0
+ /* This handles the case where a variable is found in both the temporary
+ environment *and* declared as a local variable. If we want to avoid
+ multiple entries with the same name in VC->table (that might mess up
+ unset), we need to use the existing variable entry and destroy the
+ current value. Currently disabled because it doesn't matter -- the
+ right things happen. */
+ new_var = 0;
+ if (was_tmpvar && (new_var = hash_lookup (name, vc->table)))
+ {
+ dispose_variable_value (new_var);
+ init_variable (new_var);
+ }
+ if (new_var == 0)
+#endif
new_var = make_new_variable (name, vc->table);
/* If we found this variable in one of the temporary environments,
@@ -2742,16 +2759,9 @@ set_local_var_flags:
return (new_var);
}
-/* Create a new shell variable with name NAME. */
-static SHELL_VAR *
-new_shell_variable (name)
- const char *name;
+static void
+init_variable (SHELL_VAR *entry)
{
- SHELL_VAR *entry;
-
- entry = (SHELL_VAR *)xmalloc (sizeof (SHELL_VAR));
-
- entry->name = savestring (name);
var_setvalue (entry, (char *)NULL);
CLEAR_EXPORTSTR (entry);
@@ -2764,7 +2774,18 @@ new_shell_variable (name)
make_local_variable has the responsibility of changing the
variable context. */
entry->context = 0;
+}
+/* Create a new shell variable with name NAME. */
+static SHELL_VAR *
+new_shell_variable (const char *name)
+{
+ SHELL_VAR *entry;
+
+ entry = (SHELL_VAR *)xmalloc (sizeof (SHELL_VAR));
+
+ entry->name = savestring (name);
+ init_variable (entry);
return (entry);
}
@@ -3233,8 +3254,9 @@ bind_variable (name, value, flags)
and, if found, modify the value there before modifying it in the
shell_variables table. This allows sourced scripts to modify values
given to them in a temporary environment while modifying the variable
- value that the caller sees. */
- if (temporary_env && value) /* XXX - can value be null here? */
+ value that the caller sees. The caller can inhibit this by setting
+ ASS_NOTEMPENV in FLAGS. */
+ if (temporary_env && value && (flags & ASS_NOTEMPENV) == 0) /* XXX - can value be null here? */
bind_tempenv_variable (name, value);
/* XXX -- handle local variables here. */
@@ -4537,6 +4559,11 @@ push_temp_var (data)
v = bind_variable_internal (var->name, value_cell (var), binding_table, 0, ASS_FORCE|ASS_NOLONGJMP);
+#if defined (ARRAY_VARS)
+ if (v && (array_p (var) || assoc_p (var)))
+ arrayvar_copyval (var, v);
+#endif
+
/* XXX - should we set the context here? It shouldn't matter because of how
assign_in_env works, but we do it anyway. */
if (v)
@@ -5209,14 +5236,8 @@ push_posix_tempvar_internal (var, isbltin)
v->context = shell_variables->scope;
#if defined (ARRAY_VARS)
if (v && (array_p (var) || assoc_p (var)))
- {
- FREE (value_cell (v));
- if (array_p (var))
- var_setarray (v, array_copy (array_cell (var)));
- else
- var_setassoc (v, assoc_copy (assoc_cell (var)));
- }
-#endif
+ arrayvar_copyval (var, v);
+#endif
if (shell_variables == global_variables)
var->attributes &= ~(att_tempvar|att_propagate);
else
--
2.33.0

View File

@ -0,0 +1,28 @@
From 829aad36dbbeee462fa142fe2c571fd7ab735ba8 Mon Sep 17 00:00:00 2001
From: Chet Ramey <chet.ramey@case.edu>
Date: Mon, 26 Jun 2023 17:09:08 -0400
Subject: [PATCH] backport part of patch to fix small memleak in globbing
---
lib/glob/glob.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/lib/glob/glob.c b/lib/glob/glob.c
index b66af85..e4283bd 100644
--- a/lib/glob/glob.c
+++ b/lib/glob/glob.c
@@ -1446,6 +1446,12 @@ glob_filename (pathname, flags)
free ((char *) array);
else if ((dflags & GX_ALLDIRS) && filename[0] == '*' && filename[1] == '*' && filename[2] == '\0')
free (temp_results); /* expanding ** case above */
+ else if (array == temp_results)
+ /* If array == temp_results, either we assigned it above or
+ glob_dir_to_array returned temp_results because the dirname
+ was the empty string. In any case, we assume temp_results
+ has not been freed, and free it here. */
+ free (temp_results);
if (shouldbreak)
break;
--
2.33.0

View File

@ -1,6 +1,6 @@
Name: bash
Version: 5.0
Release: 17
Release: 21
Summary: It is the Bourne Again Shell
License: GPLv3
URL: https://www.gnu.org/software/bash
@ -30,8 +30,6 @@ Patch16: bash-5.0-patch16.patch
Patch17: bash-5.0-patch17.patch
Patch18: backport-bash-5.0-patch18.patch
Patch115: bash-2.05a-interpreter.patch
Patch118: bash-2.05b-pgrp_sync.patch
Patch125: bash-4.0-nobits.patch
@ -47,6 +45,12 @@ Patch136: commit-bash-20190913-snapshot.patch
Patch137:bugfix-Forbidden-non-root-user-to-clear-history.patch
Patch138:enable-dot-logout-and-source-bashrc-through-ssh.patch
Patch6001: backport-Bash-5.1-patch-12-fix-race-condition-with-child-proc.patch
Patch6002: backport-Bash-5.1-patch-16-fix-interpretation-of-multiple-ins.patch
Patch6003: backport-fix-for-nofork-comsub-command-printing-fix-for-crash.patch
Patch6004: backport-fix-small-memleak-in-globbing.patch
Patch6005: backport-fix-for-leak-when-completing-command-word-with-glob-.patch
BuildRequires: gcc bison texinfo autoconf ncurses-devel
Requires: filesystem
@ -132,20 +136,37 @@ make check
%exclude %{_infodir}/dir
%changelog
* Thu Dec 7 2023 wangyuhang<wangyuhang27@huawei.com> - 5.0-21
- del doesn't exist PATH dirs in bashrc
* Mon Dec 4 2023 hongjinghao <hongjinghao@huawei.com> - 5.0-20
- sync patches from bash community
* Sun Apr 23 2023 wangyuhang<wangyuhang27@huawei.com> - 5.0-19
- Type:bugfix
- CVE:
- SUG:NA
- DESC:sync patches from bash community
add backport-Bash-5.1-patch-12-fix-race-condition-with-child-proc.patch
add backport-Bash-5.1-patch-16-fix-interpretation-of-multiple-ins.patch
* Fri Aug 12 2022 panxiaohe <panxh.life@foxmail.com> - 5.0-18
- fix bugfix-Forbidden-non-root-user-to-clear-history.patch
* Sat May 29 2021 licihua<licihua@huawei.com> - 5.0-17
- Type:bugfix
- ID:NA
- SUG:NA
- DESC: fix quoted null string removal when using shell word expansion pattern operators
* Thu Mar 30 2021 shenyangyang<shenyangyang4@huawei.com> - 5.0-16
* Tue Mar 30 2021 shenyangyang<shenyangyang4@huawei.com> - 5.0-16
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:Rebuild for openEuler-rpm-config moving /usr/lib/rpm/openEuler/xxxx
to /usr/lib/xxxx
* Wed Jan 6 2020 Liquor <lirui130@huawei.com> - 5.0-15
* Mon Jan 6 2020 Liquor <lirui130@huawei.com> - 5.0-15
- Type:bugfix
- ID:NA
- SUG:NA

View File

@ -4,23 +4,65 @@ Date: Mon, 2 Sep 2019 22:30:32 -0400
Subject: [PATCH] bugfix-Forbidden-non-root-user-to-clear-history
---
lib/readline/history.c | 4 ++++
1 file changed, 4 insertions(+)
bashhist.c | 5 +++--
lib/readline/history.c | 7 ++++++-
lib/readline/history.h | 2 +-
3 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/bashhist.c b/bashhist.c
index d2155dc..e61bde6 100644
--- a/bashhist.c
+++ b/bashhist.c
@@ -345,8 +345,9 @@ load_history ()
void
bash_clear_history ()
{
- clear_history ();
- history_lines_this_session = 0;
+ int ret = clear_history ();
+ if (ret == 0)
+ history_lines_this_session = 0;
/* XXX - reset history_lines_read_from_file? */
}
diff --git a/lib/readline/history.c b/lib/readline/history.c
index 67158b1..8bc6a00 100644
index 67158b1..545c675 100644
--- a/lib/readline/history.c
+++ b/lib/readline/history.c
@@ -594,6 +594,10 @@ void
@@ -590,9 +590,13 @@ history_is_stifled (void)
return (history_stifled);
}
-void
+int
clear_history (void)
{
register int i;
+ uid_t uid = getuid();
+
+ if (uid)
+ return;
+ return 1;
register int i;
/* This loses because we cannot free the data. */
for (i = 0; i < history_length; i++)
@@ -604,4 +608,5 @@ clear_history (void)
history_offset = history_length = 0;
history_base = 1; /* reset history base to default */
+ return 0;
}
diff --git a/lib/readline/history.h b/lib/readline/history.h
index cc3de29..78f8f52 100644
--- a/lib/readline/history.h
+++ b/lib/readline/history.h
@@ -110,7 +110,7 @@ extern histdata_t free_history_entry PARAMS((HIST_ENTRY *));
extern HIST_ENTRY *replace_history_entry PARAMS((int, const char *, histdata_t));
/* Clear the history list and start over. */
-extern void clear_history PARAMS((void));
+extern int clear_history PARAMS((void));
/* Stifle the history list, remembering only MAX number of entries. */
extern void stifle_history PARAMS((int));
--
2.19.1
2.27.0

View File

@ -2,5 +2,4 @@
[ -f /etc/bashrc ] && . /etc/bashrc
# User environment PATH
PATH="$HOME/.local/bin:$HOME/bin:$PATH"
export PATH