summaryrefslogtreecommitdiffstats
path: root/Tests/BundleTest
diff options
context:
space:
mode:
authorSean McBride <sean@rogue-research.com>2021-10-21 16:35:57 (GMT)
committerSean McBride <sean@rogue-research.com>2021-10-25 22:23:13 (GMT)
commit5ba6e8ac59333aa574d5963332e3ef0f4c4d3514 (patch)
treed796f695e10d5ec20508cb04f4c8b3c2a6c0d742 /Tests/BundleTest
parent0ce50dd78f68b697e1ab29d52d733b87c5bfb67d (diff)
downloadCMake-5ba6e8ac59333aa574d5963332e3ef0f4c4d3514.zip
CMake-5ba6e8ac59333aa574d5963332e3ef0f4c4d3514.tar.gz
CMake-5ba6e8ac59333aa574d5963332e3ef0f4c4d3514.tar.bz2
Source: Replace most calls to sprintf with snprintf
Diffstat (limited to 'Tests/BundleTest')
-rw-r--r--Tests/BundleTest/BundleLib.cxx5
1 files changed, 3 insertions, 2 deletions
diff --git a/Tests/BundleTest/BundleLib.cxx b/Tests/BundleTest/BundleLib.cxx
index d25ad27..cfb5f7d 100644
--- a/Tests/BundleTest/BundleLib.cxx
+++ b/Tests/BundleTest/BundleLib.cxx
@@ -20,7 +20,8 @@ int findBundleFile(char* exec, const char* file)
{
int res;
char* nexec = strdup(exec);
- char* fpath = (char*)malloc(strlen(exec) + 100);
+ size_t fpathlen = strlen(nexec) + 1 + strlen(file);
+ char* fpath = (char*)malloc(fpathlen);
int cc;
int cnt = 0;
printf("Process executable name: %s\n", exec);
@@ -36,7 +37,7 @@ int findBundleFile(char* exec, const char* file)
}
}
printf("Process executable path: %s\n", nexec);
- sprintf(fpath, "%s/%s", nexec, file);
+ snprintf(fpath, fpathlen, "%s/%s", nexec, file);
printf("Check for file: %s\n", fpath);
res = fileExists(fpath);
free(nexec);