Skip to content

Commit

Permalink
secon: check selinux_raw_to_trans_context(3) for failure
Browse files Browse the repository at this point in the history
    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]>
  • Loading branch information
cgzones committed Nov 9, 2022
1 parent ae39165 commit a8a4812
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions policycoreutils/secon/secon.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a8a4812

Please sign in to comment.