VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Setup/Dir.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/Setup/Dir.c')
-rw-r--r--src/Setup/Dir.c12
1 files changed, 12 insertions, 0 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
@@ -30,8 +30,14 @@ mkfulldir (wchar_t *oriPath, BOOL bCheckonly)
struct _stat st;
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':')
goto is_root; /* keep final slash in root if present */
@@ -65,8 +71,14 @@ mkfulldir_internal (wchar_t *path)
struct _stat st;
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';
token = wcstok (tokpath, L"\\/");