Thanks to visit codestin.com
Credit goes to github.com

Skip to content

gh-112301: Add -Wformat=2 compiler option to NODIST #122474

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
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add ``-Wformat=2`` to ``NODIST`` build flags to warn about potential vulnerabilities related to format strings.
8 changes: 4 additions & 4 deletions Python/getversion.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ void _Py_InitVersion(void)
}
initialized = 1;
#ifdef Py_GIL_DISABLED
const char *buildinfo_format = "%.80s experimental free-threading build (%.80s) %.80s";
PyOS_snprintf(version, sizeof(version), "%.80s experimental free-threading build (%.80s) %.80s",
PY_VERSION, Py_GetBuildInfo(), Py_GetCompiler());
#else
const char *buildinfo_format = "%.80s (%.80s) %.80s";
#endif
PyOS_snprintf(version, sizeof(version), buildinfo_format,
PyOS_snprintf(version, sizeof(version), "%.80s (%.80s) %.80s",
PY_VERSION, Py_GetBuildInfo(), Py_GetCompiler());
#endif
}

const char *
Expand Down
6 changes: 6 additions & 0 deletions Tools/build/.warningignore_macos
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
# Keep lines sorted lexicographically to help avoid merge conflicts.
# Format example:
# /path/to/file (number of warnings in file)
Modules/_ctypes/_ctypes_test.c 1
Modules/_ctypes/callbacks.c 1
Modules/expat/siphash.h 7
Modules/expat/xmlparse.c 8
Modules/expat/xmltok.c 3
Modules/expat/xmltok_impl.c 26
Objects/mimalloc/ *
Python/pylifecycle.c 1
Python/sysmodule.c 1
Python/tracemalloc.c 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: can you please add the missing newline at EOF?

39 changes: 39 additions & 0 deletions configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2514,6 +2514,7 @@ if test "$enable_safety" = "yes"
then
AX_CHECK_COMPILE_FLAG([-fstack-protector-strong], [CFLAGS_NODIST="$CFLAGS_NODIST -fstack-protector-strong"], [AC_MSG_WARN([-fstack-protector-strong not supported])], [-Werror])
AX_CHECK_COMPILE_FLAG([-Wtrampolines], [CFLAGS_NODIST="$CFLAGS_NODIST -Wtrampolines"], [AC_MSG_WARN([-Wtrampolines not supported])], [-Werror])
AX_CHECK_COMPILE_FLAG([-Wformat -Wformat=2], [CFLAGS_NODIST="$CFLAGS_NODIST -Wformat -Wformat=2"], [AC_MSG_WARN([-Wformat and -Wformat=2 not supported])], [-Werror])
AX_CHECK_COMPILE_FLAG([-Wimplicit-fallthrough], [CFLAGS_NODIST="$CFLAGS_NODIST -Wimplicit-fallthrough"], [AC_MSG_WARN([-Wimplicit-fallthrough not supported])], [-Werror])
AX_CHECK_COMPILE_FLAG([-Werror=format-security], [CFLAGS_NODIST="$CFLAGS_NODIST -Werror=format-security"], [AC_MSG_WARN([-Werror=format-security not supported])], [-Werror])
AX_CHECK_COMPILE_FLAG([-Wbidi-chars=any], [CFLAGS_NODIST="$CFLAGS_NODIST -Wbidi-chars=any"], [AC_MSG_WARN([-Wbidi-chars=any not supported])], [-Werror])
Expand Down
Loading