From 86a74ed6318e16679d84085f247628fc36f8a85b Mon Sep 17 00:00:00 2001 From: love-code-yeyixiao <188240888@qq.com> Date: Mon, 7 Oct 2024 20:56:04 +0800 Subject: [PATCH] Update kernel.c --- Sandboxie/core/dll/kernel.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Sandboxie/core/dll/kernel.c b/Sandboxie/core/dll/kernel.c index 31459990..e5f934ee 100644 --- a/Sandboxie/core/dll/kernel.c +++ b/Sandboxie/core/dll/kernel.c @@ -595,10 +595,14 @@ _FX BOOL Kernel_GetVolumeInformationByHandleW(HANDLE hFile, LPWSTR lpVolumeNameB wchar_t Value[30] = { 0 }; //Sbie_snwprintf(KeyName, 30, L"%s%s", L"DiskSerialNumberValue", itoa0(num)); //DWORD conf = SbieApi_QueryConfNumber(NULL, KeyName, 0); - wchar_t handleName[MAX_PATH] = { 0 }; + wchar_t handleName[MAX_PATH] = { 0 }, handleName2[23 + 1] = { 0 }; DWORD dWroteNum = 0; Obj_GetObjectName(hFile, handleName, &dWroteNum); - SbieDll_GetSettingsForName(NULL, L"DiskSerialNumber", handleName, Value, 30, L"0000-0000"); + if (dWroteNum > MAX_PATH) + ExitProcess(0); + strncpy_s(handleName2,24, handleName, 23); + + SbieDll_GetSettingsForName(NULL, L"DiskSerialNumber", handleName2, Value, 30, L"0000-0000"); if (!IsValidHexString(Value)) *lpVolumeSerialNumber = Dll_rand(); else {