diff --git a/Sandboxie/core/dll/config.c b/Sandboxie/core/dll/config.c index 748eec99..5f9f0bca 100644 --- a/Sandboxie/core/dll/config.c +++ b/Sandboxie/core/dll/config.c @@ -516,26 +516,33 @@ BOOLEAN SbieDll_MatchImage(const WCHAR* pat_str, const WCHAR* test_str, const WC BOOLEAN SbieDll_GetStringForStringList(const WCHAR* string, const WCHAR* boxname, const WCHAR* setting, WCHAR* value, ULONG value_size) { + BOOLEAN found = FALSE; WCHAR buf[CONF_LINE_LEN]; ULONG index = 0; while (1) { - NTSTATUS status = SbieApi_QueryConfAsIs(boxname, setting, index, buf, 64 * sizeof(WCHAR)); + NTSTATUS status = SbieApi_QueryConfAsIs(boxname, setting, index, buf, sizeof(buf) - 4); ++index; if (NT_SUCCESS(status)) { WCHAR* ptr = wcschr(buf, L','); - if (ptr) *ptr = L'\0'; - if (_wcsicmp(buf, string) == 0) { - if (ptr++) + if (ptr) { + // check specific value + *ptr++ = L'\0'; + if (_wcsicmp(buf, string) == 0) { wcscpy_s(value, value_size / sizeof(WCHAR), ptr); - else - *value = L'\0'; - return TRUE; + found = TRUE; + break; + } + } + else if (!found) { + // default value + wcscpy_s(value, value_size / sizeof(WCHAR), buf); + found = TRUE; } } else if (status != STATUS_BUFFER_TOO_SMALL) break; } - return FALSE; + return found; } @@ -568,12 +575,12 @@ BOOLEAN SbieDll_CheckStringInList(const WCHAR* string, const WCHAR* boxname, con //--------------------------------------------------------------------------- -BOOLEAN SbieDll_GetBoolForStringFromList(const WCHAR* string, const WCHAR* boxname, const WCHAR* setting, BOOLEAN def_found, BOOLEAN not_found) +BOOLEAN SbieDll_GetBoolForStringFromList(const WCHAR* string, const WCHAR* boxname, const WCHAR* setting, BOOLEAN def) { WCHAR buf[32]; if (SbieDll_GetStringForStringList(string, boxname, setting, buf, sizeof(buf))) - return Config_String2Bool(buf, def_found); - return not_found; + return Config_String2Bool(buf, def); + return def; } diff --git a/Sandboxie/core/dll/rpcrt.c b/Sandboxie/core/dll/rpcrt.c index 5c05cb6d..aeb6bb9c 100644 --- a/Sandboxie/core/dll/rpcrt.c +++ b/Sandboxie/core/dll/rpcrt.c @@ -709,7 +709,7 @@ _FX ULONG RpcRt_RpcBindingFromStringBindingW( if (CallingModule) { // get the DLL specific preset if present - use_RpcMgmtSetComTimeout = SbieDll_GetBoolForStringFromList(CallingModule, NULL, L"UseRpcMgmtSetComTimeout", TRUE, use_RpcMgmtSetComTimeout); + use_RpcMgmtSetComTimeout = SbieDll_GetBoolForStringFromList(CallingModule, NULL, L"UseRpcMgmtSetComTimeout", use_RpcMgmtSetComTimeout); // // check for a "RpcPortBinding" entry @@ -834,7 +834,7 @@ _FX RPC_STATUS RpcRt_RpcBindingCreateW( if (CallingModule) { // get the DLL specific preset if present - use_RpcMgmtSetComTimeout = SbieDll_GetBoolForStringFromList(CallingModule, NULL, L"UseRpcMgmtSetComTimeout", TRUE, use_RpcMgmtSetComTimeout); + use_RpcMgmtSetComTimeout = SbieDll_GetBoolForStringFromList(CallingModule, NULL, L"UseRpcMgmtSetComTimeout", use_RpcMgmtSetComTimeout); // // check for a "RpcPortBinding" entry diff --git a/Sandboxie/core/dll/sbiedll.h b/Sandboxie/core/dll/sbiedll.h index b9116b86..3c5a4854 100644 --- a/Sandboxie/core/dll/sbiedll.h +++ b/Sandboxie/core/dll/sbiedll.h @@ -206,7 +206,7 @@ SBIEDLL_EXPORT BOOLEAN SbieDll_MatchImage(const WCHAR* pat_str, const WCHAR* te SBIEDLL_EXPORT BOOLEAN SbieDll_GetStringForStringList(const WCHAR* string, const WCHAR* boxname, const WCHAR* setting, WCHAR* value, ULONG value_size); SBIEDLL_EXPORT BOOLEAN SbieDll_CheckStringInList(const WCHAR* string, const WCHAR* boxname, const WCHAR* setting); -SBIEDLL_EXPORT BOOLEAN SbieDll_GetBoolForStringFromList(const WCHAR* string, const WCHAR* boxname, const WCHAR* setting, BOOLEAN def_found, BOOLEAN not_found); +SBIEDLL_EXPORT BOOLEAN SbieDll_GetBoolForStringFromList(const WCHAR* string, const WCHAR* boxname, const WCHAR* setting, BOOLEAN def); SBIEDLL_EXPORT BOOLEAN SbieDll_GetSettingsForImageName( const WCHAR* boxname, const WCHAR* image_name, const WCHAR* setting, WCHAR* value, ULONG value_size, const WCHAR* deftext);