Skip to content

Commit

Permalink
Fix passing of argument with incompatible pointer type to fts_open()
Browse files Browse the repository at this point in the history
With GCC 14, the incompatible-pointer-types warning will turn into an
error by default. Due to this, the compilation of selint with newer
versions of GCC would fail.

This patch fixes 2 calls to fts_open() where this error occurs. As
fts_open() expects an array of `char * const`, not `const char * const`,
and the documentation does not guarantee that fts_open() will not modify
the string, the argument needs to be copied (or initialized as an array
instead of a pointer).

Signed-off-by: Juraj Marcin <[email protected]>
  • Loading branch information
JurajMarcin committed Dec 6, 2023
1 parent 0fd05c3 commit d41bfb5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/startup.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ enum selint_error load_access_vectors_kernel(const char *av_path)
}

enum selint_error r = SELINT_PARSE_ERROR;
const char *paths[2] = { av_path, NULL };
char *av_path_copy = xstrdup(av_path);
char *const paths[2] = { av_path_copy, NULL };

IGNORE_CONST_DISCARD_BEGIN;
FTS *ftsp = fts_open(paths, FTS_PHYSICAL, NULL);
Expand Down Expand Up @@ -221,8 +222,8 @@ static int mark_transform_interfaces_one_file(const struct policy_node *ast) {

enum selint_error load_devel_headers(struct policy_file_list *context_files)
{
const char *header_loc = "/usr/share/selinux/devel";
const char *paths[2] = {header_loc, 0};
char header_loc[] = "/usr/share/selinux/devel";
char *const paths[2] = { header_loc, NULL };

IGNORE_CONST_DISCARD_BEGIN;
FTS *ftsp = fts_open(paths, FTS_PHYSICAL | FTS_NOSTAT, NULL);
Expand Down

0 comments on commit d41bfb5

Please sign in to comment.