Skip to content
Permalink
Browse files Browse the repository at this point in the history
Don't search in hardcoded paths on Windows
Native Windows apps don't use "/usr" path to store system dlls.
It's even more harm than good to search through these directories,
since they are used in Cygwin and it can lead to accidentaly loading
Cygwin DLLs into native Windows apps.

Hardcoded paths are disabled for MINGW and MSWIN environments only.
They are still present on Cygwin and MSYS2, because these POSIX-API
based environments don't use LoadLibrary() but dl_open() to load DLLs.
  • Loading branch information
larskanis committed Jun 1, 2018
1 parent e0fe486 commit 09e0c60
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/ffi/library.rb
Expand Up @@ -125,7 +125,7 @@ def ffi_lib(*names)
retry
else
# TODO better library lookup logic
unless libname.start_with?("/")
unless libname.start_with?("/") || FFI::Platform.windows?
path = ['/usr/lib/','/usr/local/lib/'].find do |pth|
File.exist?(pth + libname)
end
Expand Down

0 comments on commit 09e0c60

Please sign in to comment.