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

Fix passing of argument with incompatible pointer type to fts_open() #273

Merged
merged 1 commit into from
Dec 7, 2023

Conversation

JurajMarcin
Copy link
Contributor

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).

@dburgener
Copy link
Member

Seems reasonable except for the memory errors, thanks.

I'm curious though, since this is a warning upgrading to an error, I'm not getting the warning on the current code base. I'm using gcc 13.2.1 and compiling with -Wall and -Wextra (per configure.ac). The github tool chain also adds -WError. So I don't understand why I'm not seeing the existing warning (probably as an error in CI). Any ideas?

@JurajMarcin
Copy link
Contributor Author

Currently, the warning is suppressed locally by the IGNORE_CONST_DISCARD_BEGIN macro, which disables -Wincompatible-pointer-types. However, this has been caught in Fedora during test rebuilds (logs can be found here) with specially instrumented GCC that should catch these errors before the new GCC is out. The problem can be reproduced using the mentioned GCC.

@JurajMarcin
Copy link
Contributor Author

In hindsight, the function calls no longer need to be wrapped in these macros.

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]>
@dburgener dburgener merged commit fa70204 into SELinuxProject:main Dec 7, 2023
3 checks passed
@dburgener
Copy link
Member

Merged. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants