1 Star 0 Fork 30

Jason011125/sudo

forked from src-openEuler/sudo 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-CVE-2023-27320.patch 1.26 KB
一键复制 编辑 原始数据 按行查看 历史
modric 提交于 2023-03-10 10:23 +08:00 . Fix CVE-2023-27320.
diff --git a/plugins/sudoers/match_command.c b/plugins/sudoers/match_command.c
index 37d376d..bda7082 100644
--- a/plugins/sudoers/match_command.c
+++ b/plugins/sudoers/match_command.c
@@ -818,12 +818,16 @@ command_matches(const char *sudoers_cmnd, const char *sudoers_args,
/* Rule-specific runchroot, reset user_cmnd and user_stat. */
int status;
+ /* Save old user_cmnd first, set_cmnd_path() will free it. */
saved_user_cmnd = user_cmnd;
+ user_cmnd = NULL;
if (user_stat != NULL)
saved_user_stat = *user_stat;
status = set_cmnd_path(runchroot);
- if (status != FOUND)
+ if (status != FOUND) {
+ user_cmnd = saved_user_cmnd;
saved_user_cmnd = NULL;
+ }
if (info != NULL)
info->status = status;
}
diff --git a/plugins/sudoers/visudo.c b/plugins/sudoers/visudo.c
index 3f43382..ec8deab 100644
--- a/plugins/sudoers/visudo.c
+++ b/plugins/sudoers/visudo.c
@@ -260,7 +260,9 @@ main(int argc, char *argv[])
}
/* Mock up a fake sudo_user struct. */
- user_cmnd = user_base = (char *)"";
+ user_cmnd = user_base = strdup("true");
+ if (user_cmnd == NULL)
+ sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
if (geteuid() == 0) {
const char *user = getenv("SUDO_USER");
if (user != NULL && *user != '\0')
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/Jason_828e/sudo.git
git@gitee.com:Jason_828e/sudo.git
Jason_828e
sudo
sudo
master

搜索帮助