Skip to content

Commit

Permalink
Increase fortification level
Browse files Browse the repository at this point in the history
Newer versions of GCC and Clang support _FORTIFY_SOURCE=3 which
increases code safety by providing better size checks

For reference see
https://developers.redhat.com/articles/2023/02/06/how-improve-application-security-using-fortifysource3
  • Loading branch information
imwints committed Oct 18, 2023
1 parent 2a864f6 commit f41e1e6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ target_compile_definitions(btop PRIVATE
_FILE_OFFSET_BITS=64
_GLIBCXX_ASSERTIONS _LIBCPP_ENABLE_ASSERTIONS=1
# Only has an effect with optimizations enabled
$<$<NOT:$<CONFIG:Debug>>:_FORTIFY_SOURCE=2>
$<$<NOT:$<CONFIG:Debug>>:_FORTIFY_SOURCE=3>
)

target_include_directories(btop SYSTEM PRIVATE include)
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ override GOODFLAGS := $(foreach flag,$(TESTFLAGS),$(strip $(shell echo "int main
override REQFLAGS := -std=c++20
WARNFLAGS := -Wall -Wextra -pedantic
OPTFLAGS := -O2 -ftree-vectorize -flto=$(LTO)
LDCXXFLAGS := -pthread -D_FORTIFY_SOURCE=2 -D_GLIBCXX_ASSERTIONS -D_FILE_OFFSET_BITS=64 $(GOODFLAGS) $(ADDFLAGS)
LDCXXFLAGS := -pthread -D_FORTIFY_SOURCE=3 -D_GLIBCXX_ASSERTIONS -D_FILE_OFFSET_BITS=64 $(GOODFLAGS) $(ADDFLAGS)
override CXXFLAGS += $(REQFLAGS) $(LDCXXFLAGS) $(OPTFLAGS) $(WARNFLAGS)
override LDFLAGS += $(LDCXXFLAGS) $(OPTFLAGS) $(WARNFLAGS)
INC := $(foreach incdir,$(INCDIRS),-isystem $(incdir)) -I$(SRCDIR)
Expand Down

0 comments on commit f41e1e6

Please sign in to comment.