Skip to content

Commit 4b13728

Browse files
committed
secon: check selinux_raw_to_trans_context(3) for failure
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 <[email protected]>
1 parent bc7a70e commit 4b13728

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

policycoreutils/secon/secon.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include <stdlib.h>
33
#include <stdio.h>
44
#include <assert.h>
5-
5+
#include <errno.h>
66
#include <string.h>
77

88
#define xstreq(x, y) !strcmp(x, y)
@@ -631,7 +631,10 @@ static void disp_con(const char *scon_raw)
631631
char *color_str = NULL;
632632
struct context_color_t color = { .valid = 0 };
633633

634-
selinux_raw_to_trans_context(scon_raw, &scon_trans);
634+
if (selinux_raw_to_trans_context(scon_raw, &scon_trans) < 0)
635+
errx(EXIT_FAILURE, "Couldn't convert context %s: %s",
636+
scon_raw, strerror(errno));
637+
635638
if (opts->disp_raw)
636639
scon = scon_raw;
637640
else

0 commit comments

Comments
 (0)