1 Star 0 Fork 38

氩气放电管/bash

forked from src-openEuler/bash 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-fix-for-leak-when-completing-command-word-with-glob-.patch 2.41 KB
一键复制 编辑 原始数据 按行查看 历史
hongjinghao 提交于 2023-12-04 17:12 . sync patches from bash community
From 7f7ee0e9c6766ff5d3de542d03c59590c4a5a44a Mon Sep 17 00:00:00 2001
From: Chet Ramey <[email protected]>
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
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/cyanite/bash.git
[email protected]:cyanite/bash.git
cyanite
bash
bash
master

搜索帮助