Skip to content

Commit

Permalink
apparmor: Fix wrong determination whether crun is confined
Browse files Browse the repository at this point in the history
Closes: containers#1385
Signed-off-by: 馃槑Mostafa Emami <mustafaemami@gmail.com>
  • Loading branch information
idleroamer committed Feb 2, 2024
1 parent 5078ce6 commit 98deadd
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/libcrun/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,9 @@ is_current_process_confined (libcrun_error_t *err)
if (UNLIKELY (bytes_read < 0))
return crun_make_error (err, errno, "error reading file `%s`", attr_path);

return (strncmp (buf, "unconfined", bytes_read) != 0 && buf[0] != '\0');
#define UNCONFINED "unconfined"
#define UNCONFINED_LEN (sizeof (UNCONFINED) - 1)
return bytes_read >= UNCONFINED_LEN && memcmp (buf, UNCONFINED, UNCONFINED_LEN);
}

int
Expand Down

0 comments on commit 98deadd

Please sign in to comment.