diff mbox series

[11/47] libsemanage: check memory allocations

Message ID 20241111141706.38039-11-cgoettsche@seltendoof.de (mailing list archive)
State New
Delegated to: Petr Lautrbach
Headers show
Series [01/47] libsemanage: white space cleanup | expand

Commit Message

Christian Göttsche Nov. 11, 2024, 2:16 p.m. UTC
From: Christian Göttsche <cgzones@googlemail.com>

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
 libsemanage/src/conf-parse.y | 6 ++++++
 libsemanage/src/handle.c     | 2 ++
 2 files changed, 8 insertions(+)
diff mbox series

Patch

diff --git a/libsemanage/src/conf-parse.y b/libsemanage/src/conf-parse.y
index 9e58345a..9c806fdd 100644
--- a/libsemanage/src/conf-parse.y
+++ b/libsemanage/src/conf-parse.y
@@ -369,6 +369,12 @@  static int semanage_conf_init(semanage_conf_t * conf)
 	conf->save_previous = 0;
 	conf->save_linked = 0;
 
+	if (!conf->store_path ||
+	    !conf->store_root_path ||
+	    !conf->compiler_directory_path) {
+		return -1;
+	}
+
 	if ((conf->load_policy =
 	     calloc(1, sizeof(*(current_conf->load_policy)))) == NULL) {
 		return -1;
diff --git a/libsemanage/src/handle.c b/libsemanage/src/handle.c
index d5baa614..f048f6d7 100644
--- a/libsemanage/src/handle.c
+++ b/libsemanage/src/handle.c
@@ -45,6 +45,8 @@  int semanage_set_root(const char *root)
 {
 	free(private_semanage_root);
 	private_semanage_root = strdup(root);
+	if (!private_semanage_root)
+		return -1;
 	return 0;
 }