[PATCH 22/84] libselinux: sefcontontext_compile: Add error handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


   This patch looks good to me. acked.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.13 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAlD+pPsACgkQrlYvE4MpobOPbQCeLToHug/9rYu0ylGcPom2NOFT
LfMAoKXiEZ77TbLFvQzSQuKustvIMQNt
=T3Ng
-----END PGP SIGNATURE-----
>From 04c7744497cca0365b08bafb932930fc49953155 Mon Sep 17 00:00:00 2001
From: rhatdan <dwalsh@xxxxxxxxxx>
Date: Fri, 14 Sep 2012 10:51:09 -0400
Subject: [PATCH 22/84] libselinux: sefcontontext_compile: Add error handling
 to help debug problems in libsemanage.

---
 libselinux/utils/sefcontext_compile.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/libselinux/utils/sefcontext_compile.c b/libselinux/utils/sefcontext_compile.c
index f8a5fea..15cc836 100644
--- a/libselinux/utils/sefcontext_compile.c
+++ b/libselinux/utils/sefcontext_compile.c
@@ -19,8 +19,10 @@ static int process_file(struct saved_data *data, const char *filename)
 	FILE *context_file;
 
 	context_file = fopen(filename, "r");
-	if (!context_file)
+	if (!context_file) {
+		fprintf(stderr, "Error opening %s: %s\n", filename, strerror(errno));
 		return -1;
+	}
 
 	line_num = 0;
 	while ((len = getline(&line_buf, &line_len, context_file)) != -1) {
@@ -58,8 +60,10 @@ static int process_file(struct saved_data *data, const char *filename)
 		}
 
 		rc = grow_specs(data);
-		if (rc)
+		if (rc) {
+			fprintf(stderr, "grow_specs failed: %s\n", strerror(errno));
 			return rc;
+		}
 
 		spec = &data->spec_arr[data->nspec];
 
@@ -81,9 +85,10 @@ static int process_file(struct saved_data *data, const char *filename)
 
 		regex_len = strlen(regex);
 		cp = anchored_regex = malloc(regex_len + 3);
-		if (!cp)
+		if (!cp) {
+			fprintf(stderr, "Malloc Failed: %s\n", strerror(errno));
 			return -1;
-
+		}
 		*cp++ = '^';
 		memcpy(cp, regex, regex_len);
 		cp += regex_len;
-- 
1.8.1


[Index of Archives]     [Selinux Refpolicy]     [Linux SGX]     [Fedora Users]     [Fedora Desktop]     [Yosemite Photos]     [Yosemite Camping]     [Yosemite Campsites]     [KDE Users]     [Gnome Users]

  Powered by Linux