2
0
Fork 0
forked from zynk/zynk

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.
This commit is contained in:
Johannes Findeisen 2026-07-24 03:30:11 +02:00
commit e51a77123e
2 changed files with 3 additions and 4 deletions

View file

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

View file

@ -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
$<$<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>,$<CONFIG:MinSizeRel>>:_FORTIFY_SOURCE=3>)
-Wstrict-prototypes -pedantic -fstack-protector-strong
$<$<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>,$<CONFIG:MinSizeRel>>:SHELL:-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3>)
target_link_options(zynk PRIVATE -Wl,-z,relro,-z,now -Wl,-z,noexecstack)
endif()
endif()