From 1a40f520978dc857fc54cc2b4e03b1b4ccb6ae82 Mon Sep 17 00:00:00 2001 From: Yaroslav Yamshchikov Date: Thu, 18 Jul 2019 13:14:14 +0300 Subject: [PATCH] add access(2) call before dlopening files --- src/pal/src/loader/module.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/pal/src/loader/module.cpp b/src/pal/src/loader/module.cpp index dc4c8ba..c817ffe 100644 --- a/src/pal/src/loader/module.cpp +++ b/src/pal/src/loader/module.cpp @@ -1428,6 +1428,15 @@ static NATIVE_LIBRARY_HANDLE LOADLoadLibraryDirect(LPCSTR libraryNameOrPath) _ASSERTE(libraryNameOrPath != nullptr); _ASSERTE(libraryNameOrPath[0] != '\0'); + if (strchr(libraryNameOrPath, '/') != nullptr) + { + if (access(libraryNameOrPath, F_OK) == -1) + { + SetLastError(ERROR_MOD_NOT_FOUND); + return (NATIVE_LIBRARY_HANDLE)nullptr; + } + } + NATIVE_LIBRARY_HANDLE dl_handle = dlopen(libraryNameOrPath, RTLD_LAZY); if (dl_handle == nullptr) { -- 2.7.4