From eb59ed758d04cc35b6d612c56af0bf770e3bf544 Mon Sep 17 00:00:00 2001 From: Juraj Marcin Date: Wed, 6 Dec 2023 13:18:45 +0100 Subject: [PATCH] Fix passing of argument with incompatible pointer type to fts_open() 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 --- src/startup.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/startup.c b/src/startup.c index c54e990e..88f29ab6 100644 --- a/src/startup.c +++ b/src/startup.c @@ -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); @@ -66,6 +65,7 @@ IGNORE_CONST_DISCARD_END; file = fts_read(ftsp); } fts_close(ftsp); + free(av_path_copy); return r; } @@ -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) {