From d5f34ad49d345803767d4a1166d764f9f8485541 Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Sun, 8 Feb 2015 23:46:04 +0100 Subject: Static Code Analysis: Avoid over-flaw in arithmetic operations by adding more checks. Add extra checks. Solve various issues. --- src/Setup/Dir.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src/Setup/Dir.c') 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 #include #include +#include #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, "\\/"); } -- cgit v1.2.3