kiran-cc-daemon/0001-fix-coredump-Fix-coredump-problem-caused-by-nullpoin.patch
tangjie02 5bbc75a3dc Fix coredump problem caused by nullpointer to SPwd
Modify license to MulanPSL-2.0 in SPEC

Signed-off-by: tangjie02 <tangjie02@kylinsec.com.cn>
2022-08-09 13:43:53 +08:00

42 lines
1.6 KiB
Diff
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

From 9b8ccb8e7e8f1d45315b984ecdbf0ab19870b3dd Mon Sep 17 00:00:00 2001
From: tangjie02 <tangjie02@kylinsec.com.cn>
Date: Tue, 9 Aug 2022 10:45:00 +0800
Subject: [PATCH] fix(coredump): Fix coredump problem caused by nullpointer to
SPwd
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 修复由于访问SPwd空指针引起的崩溃问题。
Signed-off-by: tangjie02 <tangjie02@kylinsec.com.cn>
---
plugins/accounts/accounts-wrapper.cpp | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/plugins/accounts/accounts-wrapper.cpp b/plugins/accounts/accounts-wrapper.cpp
index 2cbee6c..4f313f6 100644
--- a/plugins/accounts/accounts-wrapper.cpp
+++ b/plugins/accounts/accounts-wrapper.cpp
@@ -42,13 +42,14 @@ std::vector<PasswdShadow> AccountsWrapper::get_passwds_shadows()
for (auto iter = this->passwds_.begin(); iter != this->passwds_.end(); ++iter)
{
auto spwd = this->spwds_.find(iter->first);
- if (spwd == this->spwds_.end())
+ // 如果spwd不存在可能是因为账户正在创建中这个时候不作为返回值避免出现处理空指针引起的崩溃问题
+ if (spwd != this->spwds_.end())
{
- passwds_shadows.push_back(std::make_pair(iter->second, nullptr));
+ passwds_shadows.push_back(std::make_pair(iter->second, spwd->second));
}
else
{
- passwds_shadows.push_back(std::make_pair(iter->second, spwd->second));
+ KLOG_DEBUG("The shadow info isn't found.");
}
}
--
2.33.0