Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidXanatos committed Oct 19, 2021
1 parent a3d9920 commit 0a6f5c7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
29 changes: 18 additions & 11 deletions Sandboxie/core/dll/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}


Expand Down Expand Up @@ -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;
}


4 changes: 2 additions & 2 deletions Sandboxie/core/dll/rpcrt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sandboxie/core/dll/sbiedll.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 0a6f5c7

Please sign in to comment.