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 authored and dburgener committed Dec 7, 2023
1 parent 0fd05c3 commit fa70204
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/startup.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,10 @@ 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);
IGNORE_CONST_DISCARD_END;

FTSENT *file = fts_read(ftsp);

Expand All @@ -66,6 +65,7 @@ IGNORE_CONST_DISCARD_END;
file = fts_read(ftsp);
}
fts_close(ftsp);
free(av_path_copy);

return r;
}
Expand Down Expand Up @@ -221,12 +221,10 @@ 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);
IGNORE_CONST_DISCARD_END;

FTSENT *file = fts_read(ftsp);
while (file) {
Expand Down

0 comments on commit fa70204

Please sign in to comment.