- groupmod.c: delete gr_free_members(&grp) to avoid double free - subordinateio.c: list_owner_ranges(): Fix duplicate range when username matches ID Resolves: RHEL-135902 Resolves: RHEL-114226 Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
125 lines
3.2 KiB
Diff
125 lines
3.2 KiB
Diff
From 67c42427a0941a4b47c04e8a95322be9d069ff32 Mon Sep 17 00:00:00 2001
|
|
From: Alejandro Colomar <alx@kernel.org>
|
|
Date: Tue, 15 Oct 2024 13:21:17 +0200
|
|
Subject: [PATCH] lib/string/strcmp/: streq(): Add function
|
|
|
|
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
---
|
|
lib/subordinateio.c | 9 +++++----
|
|
lib/Makefile.am | 2 ++
|
|
lib/string/strcmp/streq.c | 12 ++++++++++++
|
|
lib/string/strcmp/streq.h | 30 ++++++++++++++++++++++++++++++
|
|
4 files changed, 44 insertions(+)
|
|
create mode 100644 lib/string/strcmp/streq.c
|
|
create mode 100644 lib/string/strcmp/streq.h
|
|
|
|
diff --git a/lib/subordinateio.c b/lib/subordinateio.c
|
|
index 295df2bd..45085481 100644
|
|
--- a/lib/subordinateio.c
|
|
+++ b/lib/subordinateio.c
|
|
@@ -23,6 +23,7 @@
|
|
|
|
#include "alloc.h"
|
|
#include "string/sprintf.h"
|
|
+#include "string/strcmp/streq.h"
|
|
|
|
|
|
#define ID_SIZE 31
|
|
diff --git a/lib/Makefile.am b/lib/Makefile.am
|
|
index 4ea5ec4e..96393354 100644
|
|
--- a/lib/Makefile.am
|
|
+++ b/lib/Makefile.am
|
|
@@ -154,6 +154,8 @@ libshadow_la_SOURCES = \
|
|
string/strtcpy.h \
|
|
string/zustr2stp.c \
|
|
string/zustr2stp.h \
|
|
+ string/strcmp/streq.c \
|
|
+ string/strcmp/streq.h \
|
|
strtoday.c \
|
|
sub.c \
|
|
subordinateio.h \
|
|
diff --git a/lib/string/strcmp/streq.c b/lib/string/strcmp/streq.c
|
|
new file mode 100644
|
|
index 00000000..52057ed8
|
|
--- /dev/null
|
|
+++ b/lib/string/strcmp/streq.c
|
|
@@ -0,0 +1,12 @@
|
|
+// SPDX-FileCopyrightText: 2024, Alejandro Colomar <alx@kernel.org>
|
|
+// SPDX-License-Identifier: BSD-3-Clause
|
|
+
|
|
+
|
|
+#include <config.h>
|
|
+
|
|
+#include <stdbool.h>
|
|
+
|
|
+#include "string/strcmp/streq.h"
|
|
+
|
|
+
|
|
+extern inline bool streq(const char *s1, const char *s2);
|
|
diff --git a/lib/string/strcmp/streq.h b/lib/string/strcmp/streq.h
|
|
new file mode 100644
|
|
index 00000000..267045c5
|
|
--- /dev/null
|
|
+++ b/lib/string/strcmp/streq.h
|
|
@@ -0,0 +1,30 @@
|
|
+// SPDX-FileCopyrightText: 2024, Alejandro Colomar <alx@kernel.org>
|
|
+// SPDX-License-Identifier: BSD-3-Clause
|
|
+
|
|
+
|
|
+#ifndef SHADOW_INCLUDE_LIB_STRING_STRCMP_STREQ_H_
|
|
+#define SHADOW_INCLUDE_LIB_STRING_STRCMP_STREQ_H_
|
|
+
|
|
+
|
|
+#include <config.h>
|
|
+
|
|
+#include <stdbool.h>
|
|
+#include <string.h>
|
|
+
|
|
+#include "attr.h"
|
|
+
|
|
+
|
|
+ATTR_STRING(1)
|
|
+ATTR_STRING(2)
|
|
+inline bool streq(const char *s1, const char *s2);
|
|
+
|
|
+
|
|
+/* Return true if s1 and s2 compare equal. */
|
|
+inline bool
|
|
+streq(const char *s1, const char *s2)
|
|
+{
|
|
+ return strcmp(s1, s2) == 0;
|
|
+}
|
|
+
|
|
+
|
|
+#endif // include guard
|
|
--
|
|
2.54.0
|
|
|
|
|
|
diff -up shadow-4.15.0/lib/subordinateio.c.orig shadow-4.15.0/lib/subordinateio.c
|
|
--- shadow-4.15.0/lib/subordinateio.c.orig 2026-05-14 15:54:21.131636830 +0200
|
|
+++ shadow-4.15.0/lib/subordinateio.c 2026-05-14 15:54:35.544472143 +0200
|
|
@@ -868,18 +868,10 @@ int list_owner_ranges(const char *owner,
|
|
have_owner_id = get_owner_id(owner, id_type, id);
|
|
|
|
commonio_rewind(db);
|
|
- while ((range = commonio_next(db)) != NULL) {
|
|
- if (0 == strcmp(range->owner, owner)) {
|
|
- if (!append_range(&ranges, range, count++)) {
|
|
- free(ranges);
|
|
- ranges = NULL;
|
|
- count = -1;
|
|
- goto out;
|
|
- }
|
|
- }
|
|
-
|
|
- // Let's also compare with the ID
|
|
- if (have_owner_id == true && 0 == strcmp(range->owner, id)) {
|
|
+ while (NULL != (range = commonio_next(db))) {
|
|
+ if ( streq(range->owner, owner)
|
|
+ || (have_owner_id && streq(range->owner, id)))
|
|
+ {
|
|
if (!append_range(&ranges, range, count++)) {
|
|
free(ranges);
|
|
ranges = NULL;
|