forked from weaselab/weaseljson
Guard --nobranchprotection behind a version check
Older versions of hardening-check (as shipped by some Ubuntu releases) don't support --nobranchprotection and error out. Probe --help at configure time and only add the flag when it's available; old versions that lack the flag also don't check for branch protection, so omitting it is safe.
This commit is contained in:
@@ -212,7 +212,17 @@ if(NOT CMAKE_CROSSCOMPILING)
|
|||||||
STREQUAL arm64)
|
STREQUAL arm64)
|
||||||
set(hardening_check_arch_flags --nocfprotection)
|
set(hardening_check_arch_flags --nocfprotection)
|
||||||
else()
|
else()
|
||||||
|
# --nobranchprotection was added in a newer version of hardening-check;
|
||||||
|
# older versions don't check for it either, so omitting the flag is safe.
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${HARDENING_CHECK} --help
|
||||||
|
OUTPUT_VARIABLE _hardening_check_help
|
||||||
|
ERROR_VARIABLE _hardening_check_help)
|
||||||
|
if(_hardening_check_help MATCHES "nobranchprotection")
|
||||||
set(hardening_check_arch_flags --nobranchprotection)
|
set(hardening_check_arch_flags --nobranchprotection)
|
||||||
|
else()
|
||||||
|
set(hardening_check_arch_flags "")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
add_test(
|
add_test(
|
||||||
NAME hardening_check
|
NAME hardening_check
|
||||||
|
|||||||
Reference in New Issue
Block a user