VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Setup/Dir.c
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2015-02-08 23:46:04 +0100
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2015-02-09 11:01:21 +0100
commitd5f34ad49d345803767d4a1166d764f9f8485541 (patch)
treea101ab51e55dffdbcdef4c15596fd9418df421cd /src/Setup/Dir.c
parent608e86c7bc962f369003d9d05d4402f9da273f0c (diff)
downloadVeraCrypt-d5f34ad49d345803767d4a1166d764f9f8485541.tar.gz
VeraCrypt-d5f34ad49d345803767d4a1166d764f9f8485541.zip
Static Code Analysis: Avoid over-flaw in arithmetic operations by adding more checks. Add extra checks. Solve various issues.
Diffstat (limited to 'src/Setup/Dir.c')
-rw-r--r--src/Setup/Dir.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/Setup/Dir.c b/src/Setup/Dir.c
index a0380ef2..ec530df4 100644
--- a/src/Setup/Dir.c
+++ b/src/Setup/Dir.c
@@ -17,6 +17,7 @@
#include <string.h>
#include <stdlib.h>
#include <errno.h>
+#include <Strsafe.h>
#include "Dir.h"
@@ -28,7 +29,7 @@ mkfulldir (char *oriPath, BOOL bCheckonly)
char *uniq_file;
char path [TC_MAX_PATH];
- strcpy (path, oriPath);
+ StringCbCopyA (path, TC_MAX_PATH, oriPath);
if (strlen (path) == 3 && path[1] == ':')
goto is_root; /* keep final slash in root if present */
@@ -63,7 +64,7 @@ mkfulldir_internal (char *path)
static char tokpath[_MAX_PATH];
static char trail[_MAX_PATH];
- strcpy (tokpath, path);
+ StringCbCopyA (tokpath, _MAX_PATH, path);
trail[0] = '\0';
token = strtok (tokpath, "\\/");
@@ -75,13 +76,13 @@ mkfulldir_internal (char *path)
trail[2] = '\0';
if (token)
{
- strcat (trail, token);
- strcat (trail, "\\");
+ StringCbCatA (trail, _MAX_PATH, token);
+ StringCbCatA (trail, _MAX_PATH, "\\");
token = strtok (NULL, "\\/");
if (token)
{ /* get share name */
- strcat (trail, token);
- strcat (trail, "\\");
+ StringCbCatA (trail, _MAX_PATH, token);
+ StringCbCatA (trail, _MAX_PATH, "\\");
}
token = strtok (NULL, "\\/");
}
@@ -89,17 +90,17 @@ mkfulldir_internal (char *path)
if (tokpath[1] == ':')
{ /* drive letter */
- strcat (trail, tokpath);
- strcat (trail, "\\");
+ StringCbCatA (trail, _MAX_PATH, tokpath);
+ StringCbCatA (trail, _MAX_PATH, "\\");
token = strtok (NULL, "\\/");
}
while (token != NULL)
{
int x;
- strcat (trail, token);
+ StringCbCatA (trail, _MAX_PATH, token);
x = _mkdir (trail);
- strcat (trail, "\\");
+ StringCbCatA (trail, _MAX_PATH, "\\");
token = strtok (NULL, "\\/");
}