From 1a34f648587436c85c4b5dbcccf6f4a8de798dde Mon Sep 17 00:00:00 2001 From: panxiaohe Date: Fri, 28 Jan 2022 16:02:14 +0800 Subject: [PATCH] groupdel: fix SIGSEGV when passwd does not exist --- ...x-SIGSEGV-when-passwd-does-not-exist.patch | 32 +++++++++++++++++++ shadow.spec | 6 +++- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 groupdel-fix-SIGSEGV-when-passwd-does-not-exist.patch diff --git a/groupdel-fix-SIGSEGV-when-passwd-does-not-exist.patch b/groupdel-fix-SIGSEGV-when-passwd-does-not-exist.patch new file mode 100644 index 0000000..5a790da --- /dev/null +++ b/groupdel-fix-SIGSEGV-when-passwd-does-not-exist.patch @@ -0,0 +1,32 @@ +From a757b458ffb4fb9a40bcbb4f7869449431c67f83 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Fran=C3=A7ois=20Rigault?= +Date: Mon, 1 Nov 2021 13:54:25 +0100 +Subject: [PATCH] groupdel: fix SIGSEGV when passwd does not exist + +When using groupdel with a prefix, groupdel will attempt to read a +passwd file to look for any user in the group. When the file does not +exist it cores with segmentation fault. + +Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1986111 +Conflict: context adaptation +--- + libmisc/prefix_flag.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/libmisc/prefix_flag.c b/libmisc/prefix_flag.c +index cca553a..b6628ac 100644 +--- a/libmisc/prefix_flag.c ++++ b/libmisc/prefix_flag.c +@@ -288,6 +288,9 @@ extern struct passwd* prefix_getpwent() + if(!passwd_db_file) { + return getpwent(); + } ++ if (!fp_pwent) { ++ return NULL; ++ } + return fgetpwent(fp_pwent); + } + extern void prefix_endpwent() +-- +1.8.3.1 + diff --git a/shadow.spec b/shadow.spec index 0e04f8f..82056c8 100644 --- a/shadow.spec +++ b/shadow.spec @@ -1,6 +1,6 @@ Name: shadow Version: 4.8.1 -Release: 4 +Release: 5 Epoch: 2 License: BSD and GPLv2+ Summary: Tools for managing accounts and shadow password files @@ -23,6 +23,7 @@ Patch6: add-home_mode-xml-file.patch Patch7: shadow-4.1.5.1-var-lock.patch Patch8: shadow-utils-fix-lock-file-residue.patch Patch9: shadow-add-sm3-crypt-support.patch +Patch10: groupdel-fix-SIGSEGV-when-passwd-does-not-exist.patch BuildRequires: gcc, libselinux-devel, audit-libs-devel, libsemanage-devel BuildRequires: libacl-devel, libattr-devel gdb @@ -169,6 +170,9 @@ done %{_mandir}/*/* %changelog +* Fri Jan 28 2022 panxiaohe - 2:4.8.1-5 +- groupdel: fix SIGSEGV when passwd does not exist + * Sat Oct 30 2021 wangcheng - 2:4.8.1-4 - add sm3 crypt support -- Gitee