[RFC PATCH 7/9] secon: check selinux_raw_to_trans_context(3) for failure

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

 



    secon.c: In function ‘disp_con’:
    secon.c:634:9: error: ignoring return value of ‘selinux_raw_to_trans_context’ declared with attribute ‘warn_unused_result’ [-Werror=unused-result]
      634 |         selinux_raw_to_trans_context(scon_raw, &scon_trans);
          |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Christian Göttsche <cgzones@xxxxxxxxxxxxxx>
---
 policycoreutils/secon/secon.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/policycoreutils/secon/secon.c b/policycoreutils/secon/secon.c
index d624fa13..82266894 100644
--- a/policycoreutils/secon/secon.c
+++ b/policycoreutils/secon/secon.c
@@ -2,7 +2,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <assert.h>
-
+#include <errno.h>
 #include <string.h>
 
 #define xstreq(x, y) !strcmp(x, y)
@@ -631,7 +631,10 @@ static void disp_con(const char *scon_raw)
 	char *color_str = NULL;
 	struct context_color_t color = { .valid = 0 };
 
-	selinux_raw_to_trans_context(scon_raw, &scon_trans);
+	if (selinux_raw_to_trans_context(scon_raw, &scon_trans) < 0)
+		errx(EXIT_FAILURE, "Couldn't convert context %s:  %s",
+		     scon_raw, strerror(errno));
+
 	if (opts->disp_raw)
 		scon = scon_raw;
 	else
-- 
2.40.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