libcap/backport-Address-some-static-analysis-observations.patch

31 lines
958 B
Diff
Raw Permalink Normal View History

2025-03-13 15:03:51 +08:00
From a044d8b496ef598c61f0634172c742bd52ccf776 Mon Sep 17 00:00:00 2001
From: "Andrew G. Morgan" <morgan@kernel.org>
Date: Fri, 15 Nov 2024 07:26:42 -0800
Subject: [PATCH] Address some static analysis observations.
These were reported by Carlos Rodriguez-Fernandez with respect
to some analysis performed on the Fedora libcap-2.71 package.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
---
pam_cap/pam_cap.c | 3 +++++-
1 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/pam_cap/pam_cap.c b/pam_cap/pam_cap.c
index 3fe3b8c..24de329 100644
--- a/pam_cap/pam_cap.c
+++ b/pam_cap/pam_cap.c
@@ -170,7 +170,8 @@ static char *read_capabilities_for_user(const char *user, const char *source)
int i;
for (i=0; i < groups_n; i++) {
- if (!strcmp(groups[i], line+1)) {
+ const char *g = groups[i];
+ if (g != NULL && !strcmp(g, line+1)) {
D(("user group matched [%s]", line));
found_one = 1;
break;
--
2.33.0