mirror of
https://github.com/amadvance/snapraid.git
synced 2026-11-21 23:46:27 -05:00
Harden PowerShell execution with safe SearchPathW and os_spawn
This commit is contained in:
parent
0669f03754
commit
2c5390ecf1
2 changed files with 69 additions and 25 deletions
11
os/mingw.c
11
os/mingw.c
|
|
@ -33,6 +33,14 @@
|
|||
#define WIN32_ES_CONTINUOUS 0x80000000L
|
||||
#endif
|
||||
|
||||
/* For SetSearchPathMode */
|
||||
#ifndef BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE
|
||||
#define BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE 0x00000001
|
||||
#endif
|
||||
#ifndef BASE_SEARCH_PATH_PERMANENT
|
||||
#define BASE_SEARCH_PATH_PERMANENT 0x00008000
|
||||
#endif
|
||||
|
||||
/* File Index */
|
||||
#undef FILE_INVALID_FILE_ID
|
||||
#define FILE_INVALID_FILE_ID ((ULONGLONG)-1LL)
|
||||
|
|
@ -3611,6 +3619,9 @@ void os_init(unsigned opt)
|
|||
os_exit();
|
||||
}
|
||||
|
||||
/* enable safe search path mode permanently to prevent binary hijacking from CWD */
|
||||
SetSearchPathMode(BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE | BASE_SEARCH_PATH_PERMANENT);
|
||||
|
||||
dll_advapi32 = LoadLibrary("ADVAPI32.DLL");
|
||||
if (!dll_advapi32) {
|
||||
os_syslog(OS_LVL_CRITICAL, "error loading the ADVAPI32 module");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue