diff mbox series

[v2,3/9] libsemanage: handle shell allocation failure

Message ID 20241125111840.63845-3-cgoettsche@seltendoof.de (mailing list archive)
State New
Headers show
Series [v2,1/9] libsemanage: set O_CLOEXEC flag for file descriptors | expand

Commit Message

Christian Göttsche Nov. 25, 2024, 11:18 a.m. UTC
From: Christian Göttsche <cgzones@googlemail.com>

Return failure instead of silently using a fallback.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
 libsemanage/src/genhomedircon.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/libsemanage/src/genhomedircon.c b/libsemanage/src/genhomedircon.c
index 53673645..c38d284b 100644
--- a/libsemanage/src/genhomedircon.c
+++ b/libsemanage/src/genhomedircon.c
@@ -228,7 +228,7 @@  static semanage_list_t *get_shell_list(void)
 				free(temp);
 				semanage_list_destroy(&list);
 				fclose(shells);
-				return default_shell_list();
+				return NULL;
 			}
 		}
 	}
@@ -333,7 +333,10 @@  static semanage_list_t *get_home_dirs(genhomedircon_settings_t * s)
 		return homedir_list;
 
 	shells = get_shell_list();
-	assert(shells);
+	if (!shells) {
+		ERR(s->h_semanage, "Allocation failure!");
+		goto fail;
+	}
 
 	path = semanage_findval(PATH_ETC_LOGIN_DEFS, "UID_MIN", NULL);
 	if (path && *path) {