1 Star 0 Fork 37

ikernel_Mryao/shadow

forked from src-openEuler/shadow 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-Initialize-local-variables.patch 2.85 KB
一键复制 编辑 原始数据 按行查看 历史
yunjia_w 提交于 2022-10-31 11:00 +08:00 . add some backport to optimize some functions
From 3b89b71680b2eb46135439e0a7760dbe040628e5 Mon Sep 17 00:00:00 2001
From: Iker Pedrosa <ipedrosa@redhat.com>
Date: Mon, 16 May 2022 17:24:58 +0200
Subject: [PATCH] Initialize local variables
CWE-457 by CodeQL.
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Reference: https://github.com/shadow-maint/shadow/commit/3b89b71680b2eb46135439e0a7760dbe040628e5
Conflict: The number of lines is inconsistent and there is a little difference in adaptation
---
lib/run_part.c | 2 +-
src/faillog.c | 4 ++--
src/lastlog.c | 21 ++++++++++-----------
3 files changed, 13 insertions(+), 14 deletions(-)
diff --git a/lib/run_part.c b/lib/run_part.c
index 1e4f154b..bce11d37 100644
--- a/lib/run_part.c
+++ b/lib/run_part.c
@@ -43,7 +43,7 @@ int run_parts (char *directory, char *name, char *action)
struct dirent **namelist;
int scanlist;
int n;
- int execute_result;
+ int execute_result = 0;
scanlist = scandir (directory, &namelist, 0, alphasort);
if (scanlist<=0) {
diff --git a/src/faillog.c b/src/faillog.c
index d33fe9b6..0f94836f 100644
--- a/src/faillog.c
+++ b/src/faillog.c
@@ -565,9 +565,9 @@ static void set_locktime (long locktime)
int main (int argc, char **argv)
{
- long fail_locktime;
+ long fail_locktime = 0;
short fail_max = 0; // initialize to silence compiler warning
- long days;
+ long days = 0;
/*
* Get the program name. The program name is used as a prefix to
diff --git a/src/lastlog.c b/src/lastlog.c
index 3c0fc9c6..0d4b5fd2 100644
--- a/src/lastlog.c
+++ b/src/lastlog.c
@@ -114,7 +114,16 @@ static void print_one (/*@null@*/const struct passwd *pw)
#endif
#ifdef HAVE_LL_HOST
- int maxIPv6Addrlen;
+ /*
+ * ll_host is in minimized form, thus the maximum IPv6 address possible is
+ * 8*4+7 = 39 characters.
+ * RFC 4291 2.5.6 states that for LL-addresses fe80+only the interface ID is set,
+ * thus having a maximum size of 25+1+IFNAMSIZ.
+ * POSIX says IFNAMSIZ should be 16 characters long including the null byte, thus
+ * 25+1+IFNAMSIZ >= 42 > 39
+ */
+ /* Link-Local address + % + Interfacename */
+ const int maxIPv6Addrlen = 25+1+IFNAMSIZ;
#endif
if (NULL == pw) {
@@ -158,16 +167,6 @@ static void print_one (/*@null@*/const struct passwd *pw)
/* Print the header only once */
if (!once) {
#ifdef HAVE_LL_HOST
- /*
- * ll_host is in minimized form, thus the maximum IPv6 address possible is
- * 8*4+7 = 39 characters.
- * RFC 4291 2.5.6 states that for LL-addresses fe80+only the interface ID is set,
- * thus having a maximum size of 25+1+IFNAMSIZ.
- * POSIX says IFNAMSIZ should be 16 characters long including the null byte, thus
- * 25+1+IFNAMSIZ >= 42 > 39
- */
- /* Link-Local address + % + Interfacename */
- maxIPv6Addrlen = 25+1+IFNAMSIZ;
printf (_("Username Port From%*sLatest\n"), maxIPv6Addrlen-3, " ");
#else
puts (_("Username Port Latest"));
--
2.27.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ikernel-mryao/shadow.git
git@gitee.com:ikernel-mryao/shadow.git
ikernel-mryao
shadow
shadow
master

搜索帮助