Skip to content

Commit a472f45

Browse files
committed
add DEPENDENTLOADFLAG linker flag on Windows
This is to address potential DLL planting security issue, see: https://msrc.microsoft.com/blog/2018/04/triaging-a-dll-planting-vulnerability/#current-working-directory-cwd-dll-planting
1 parent a1094cd commit a472f45

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

cmake/helpers.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ function(add_ur_library name)
131131
add_library(${name} ${ARGN})
132132
add_ur_target_compile_options(${name})
133133
add_ur_target_link_options(${name})
134+
if(MSVC)
135+
target_link_options(${name} PRIVATE
136+
$<$<STREQUAL:$<TARGET_LINKER_FILE_NAME:${name}>,link.exe>:/DEPENDENTLOADFLAG:0x2000>
137+
)
138+
endif()
134139
endfunction()
135140

136141
include(FetchContent)

0 commit comments

Comments
 (0)