From 1832295cd1bba7703deb38748dba86e59558f78e Mon Sep 17 00:00:00 2001 From: Disconnect3d Date: Tue, 27 Dec 2022 15:06:40 +0100 Subject: [PATCH] Makefile: fix the _FORTIFY_SOURCE define This commit fixes the mistake in the `_FORTIFY_SOURCE` macro where it was not prefixed with underscore while it has to be (see e.g. https://github.com/search?q=repo%3Abminor%2Fglibc%20FORTIFY_SOURCE&type=code). Additionally, to make this macro add extra security, one has to enable optimizations. Currently, the Makefile sets `-O0` which effectively disables the mitigations added by this macro. Overall, I would recommend using `-D_FORTIFY_SOURCE=3` with `-O2` or `-O3`. (The fortify source level 3 was added recently and you can read more about it here: https://developers.redhat.com/blog/2021/04/16/broadening-compiler-checks-for-buffer-overflows-in-_fortify_source). --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d4ae403..7a4ac66 100644 --- a/Makefile +++ b/Makefile @@ -68,7 +68,7 @@ CPPFILES = $(foreach dir, $(call SRCDIRS, $(1)), $(wildcard $(dir)/*.cpp)) SRCFILES = $(foreach dir, $(call SRCDIRS, $(1)), $(wildcard $(dir)/*.c)) # Setup the Defines -DEFINES += -D_REENTRANT -DFORTIFY_SOURCE=2 -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -DHAVE_NS_TYPE -DDIME_BUILD=$(LIBDIME_VERSION) -DDIME_STAMP=$(LIBDIME_TIMESTAMP) +DEFINES += -D_REENTRANT -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -DHAVE_NS_TYPE -DDIME_BUILD=$(LIBDIME_VERSION) -DDIME_STAMP=$(LIBDIME_TIMESTAMP) INCLUDES = -Isrc -Isrc/providers -Ilib/local/include -I/usr/include WARNINGS = -Wfatal-errors -Werror -Wall -Wextra -Wformat-security -Warray-bounds -Wformat=2 -Wno-format-nonliteral