Skip to content

Consider -Wstringop-overflow, -Wno-stringop-overread, and -Wno-stringop-truncation for C and C++ Compiler Hardening Guide #882

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

Open
thomasnyman opened this issue May 7, 2025 · 0 comments

Comments

@thomasnyman
Copy link
Contributor

The -Wstringop-overflow, -Wno-stringop-overread, and -Wno-stringop-truncation options warn for code that can be statically determined to cause buffer overflows or memory overruns, truncate the copied string or leave the destination unchanged.

-Wstringop-overflow, in particular, was briefly enabled in Linux 6.8 but ultimately disabled due non-x86_64 build issues (without exact cause).

These options also benefit from GCC access attribute annotations which may make them worth considering.

Resources:

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

No branches or pull requests

1 participant