summaryrefslogtreecommitdiffstats
path: root/Tests/BundleTest/BundleLib.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/BundleTest/BundleLib.cxx')
-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);