diff options
author | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2022-03-26 20:03:19 +0100 |
---|---|---|
committer | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2022-03-26 21:15:11 +0100 |
commit | 762065917f3ac47c3bdcacdb608d35b36dfb3973 (patch) | |
tree | 7863397c35f5e560c28150879307acec6c18b3d2 /src/Setup | |
parent | a0809fe85c2f1bf130c26ff77aea7dac19b6c05f (diff) | |
download | VeraCrypt-762065917f3ac47c3bdcacdb608d35b36dfb3973.tar.gz VeraCrypt-762065917f3ac47c3bdcacdb608d35b36dfb3973.zip |
Windows: Add various checks to address Coverity reported issues.
Diffstat (limited to 'src/Setup')
-rw-r--r-- | src/Setup/Dir.c | 12 | ||||
-rw-r--r-- | src/Setup/Setup.c | 3 |
2 files changed, 14 insertions, 1 deletions
diff --git a/src/Setup/Dir.c b/src/Setup/Dir.c index 2d4feecd..3275567f 100644 --- a/src/Setup/Dir.c +++ b/src/Setup/Dir.c @@ -31,6 +31,12 @@ mkfulldir (wchar_t *oriPath, BOOL bCheckonly) wchar_t *uniq_file; wchar_t path [TC_MAX_PATH]; + if (wcslen(oriPath) >= TC_MAX_PATH) + { + // directory name will be truncated so return failure to avoid unexepected behavior + return -1; + } + StringCbCopyW (path, TC_MAX_PATH, oriPath); if (wcslen (path) == 3 && path[1] == L':') @@ -66,6 +72,12 @@ mkfulldir_internal (wchar_t *path) static wchar_t tokpath[_MAX_PATH]; static wchar_t trail[_MAX_PATH]; + if (wcslen(path) >= _MAX_PATH) + { + // directory name will be truncated so return failure to avoid unexepected behavior + return -1; + } + StringCbCopyW (tokpath, _MAX_PATH, path); trail[0] = L'\0'; diff --git a/src/Setup/Setup.c b/src/Setup/Setup.c index 9433bd40..43c951f5 100644 --- a/src/Setup/Setup.c +++ b/src/Setup/Setup.c @@ -819,7 +819,8 @@ BOOL DoFilesInstall (HWND hwndDlg, wchar_t *szDestDir) if (Is64BitOs ()) driver64 = TRUE; - GetSystemDirectory (szDir, ARRAYSIZE (szDir)); + if (!GetSystemDirectory (szDir, ARRAYSIZE (szDir))) + StringCbCopyW(szDir, sizeof(szDir), L"C:\\Windows\\System32"); x = wcslen (szDir); if (szDir[x - 1] != L'\\') |