Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Annotate libselinux functions #357

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
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]>
  • Loading branch information
cgzones committed May 12, 2023
commit 9ff1915e457984f7c9ab8dd99da0e768a156bfde
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