From e51a77123e4a9f4f68f5d01d5e0d732d805bd98b Mon Sep 17 00:00:00 2001 From: hanez Date: Fri, 24 Jul 2026 03:30:11 +0200 Subject: [PATCH] Fix _FORTIFY_SOURCE redefinition warning on musl/Alpine. (0.40.7) - Moved _FORTIFY_SOURCE=3 from target_compile_definitions to target_compile_options with a preceding -U_FORTIFY_SOURCE via the SHELL: prefix to prevent redefinition warnings on musl/Alpine where the compiler already defines it via built-in macros. - The SHELL: prefix ensures both flags stay together and in the correct order on the compile command line. - Updated CHANGELOG.md entry for 0.40.7 with the fix. --- CHANGELOG.md | 2 +- CMakeLists.txt | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b1bc816..5543292 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ - Added `secure_state_open()`: hardened file open with O_CLOEXEC, O_NOFOLLOW, mode 0600, regular-file and ownership checks. Prevents symlink attacks, TOCTOU races, and world-writable temp files. - Replaced all `fopen()` calls for temp state files (`/tmp/zynk_reload`, `/tmp/zynk_code_restart`, `/tmp/zynk_make_err`, `/tmp/zynk_rebuild_err`) with `secure_state_open()` + `fdopen()` across hot reload, compile-restart, and rebuild paths. - Hardened TLS initialization: enforces minimum TLS 1.2 (`SSL_CTX_set_min_proto_version`), disables compression (`SSL_OP_NO_COMPRESSION`), and checks the return value of `SSL_CTX_set_default_verify_paths()` instead of ignoring failures. -- CMake compiler/linker hardening: added `-Wformat=2 -Wstrict-prototypes -fstack-protector-strong`, `_FORTIFY_SOURCE=3` for release builds, and RELRO + noexecstack linker flags. +- CMake compiler/linker hardening: added `-Wformat=2 -Wstrict-prototypes -fstack-protector-strong`, `_FORTIFY_SOURCE=3` for release builds, and RELRO + noexecstack linker flags. Fixed `_FORTIFY_SOURCE` redefinition warning on musl/Alpine by undefining before redefining via `SHELL:` prefix. - Added `!calc` input validation: rejects expressions longer than 256 chars and disallows non-numeric characters (only digits, `.`, `()`, `+-*/^%`, and whitespace are permitted). - Added `!stock` symbol validation: rejects symbols containing characters other than alphanumerics, `.`, `-`, `^`, or `=`. - Fixed `!quit`, `!reload`, `!restart` to require channel context — these commands now reject DM usage with a clear error instead of silently passing the op check. diff --git a/CMakeLists.txt b/CMakeLists.txt index 734b1f5..70ef547 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,9 +62,8 @@ add_executable(zynk zynk.c) if(BUILD_STRICT) if(CMAKE_C_COMPILER_ID MATCHES "Clang|GNU") target_compile_options(zynk PRIVATE -Wall -Wextra -Wformat=2 - -Wstrict-prototypes -pedantic -fstack-protector-strong) - target_compile_definitions(zynk PRIVATE - $<$,$,$>:_FORTIFY_SOURCE=3>) + -Wstrict-prototypes -pedantic -fstack-protector-strong + $<$,$,$>:SHELL:-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3>) target_link_options(zynk PRIVATE -Wl,-z,relro,-z,now -Wl,-z,noexecstack) endif() endif()