aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan200101 <sentrycraft123@gmail.com>2020-09-04 19:14:58 +0200
committerJan200101 <sentrycraft123@gmail.com>2020-09-04 19:14:58 +0200
commite83fafc1895d72f9c1e4bd701c90b325629ea305 (patch)
treeab958246a46b13695e0020ae9ef33c41008a2f6e
parent830bed97d2799dc26f02a37c15740af2ceada2ea (diff)
downloadpolecat-e83fafc1895d72f9c1e4bd701c90b325629ea305.tar.gz
polecat-e83fafc1895d72f9c1e4bd701c90b325629ea305.zip
correct strn sizes, replace str calls with strn variant, check wine path
-rw-r--r--src/wine.c34
1 files changed, 22 insertions, 12 deletions
diff --git a/src/wine.c b/src/wine.c
index 0f9796e..ed428ef 100644
--- a/src/wine.c
+++ b/src/wine.c
@@ -69,9 +69,9 @@ int wine_download(int argc, char** argv)
getDataDir(datadir, sizeof(datadir));
makeDir(datadir);
- strncpy(downloadpath, datadir, sizeof(downloadpath));
- strncat(downloadpath, "/", sizeof(downloadpath) - strlen(downloadpath));
- strncat(downloadpath, name, sizeof(downloadpath) - strlen(downloadpath));
+ strncpy(downloadpath, datadir, sizeof(downloadpath) - 1);
+ strncat(downloadpath, "/", sizeof(downloadpath) - strlen(downloadpath) - 1);
+ strncat(downloadpath, name, sizeof(downloadpath) - strlen(downloadpath) - 1);
printf("Downloading %s\n", name);
@@ -134,20 +134,30 @@ int wine_run(int argc, char** argv)
getDataDir(winepath, sizeof(winepath));
char* winever = argv[1];
- strcat(winepath, "/");
- strcat(winepath, winever);
- strcat(winepath, "/bin/wine");
+ strncat(winepath, "/", sizeof(winepath) - strlen(winepath) - 1);
+ strncat(winepath, winever, sizeof(winepath) - strlen(winepath) - 1);
+ strncat(winepath, "/bin/wine", sizeof(winepath) - strlen(winepath) - 1);
- for (int i = 2; i < argc; ++i)
+ if (isFile(winepath))
{
- strcat(winepath, " ");
- strcat(winepath, argv[i]);
+ for (int i = 2; i < argc; ++i)
+ {
+ strncat(winepath, " ", sizeof(winepath) - strlen(winepath) - 1);
+ strncat(winepath, argv[i], sizeof(winepath) - strlen(winepath) - 1);
+ }
+ return system(winepath);
+ }
+ else
+ {
+ printf("`%s' is not an installed wine version\n", winever);
}
- return system(winepath);
+ }
+ else
+ {
+ printf("Specify a what wine version to run.\nUse `" NAME " wine installed' to list available versions\n");
}
- printf("Specify a what wine version to run.\nUse `" NAME " wine list-installed' to list available versions\n");
return 0;
}
@@ -187,4 +197,4 @@ int wine_help(int argc, char** argv)
print_help(wine_commands, ARRAY_LEN(wine_commands));
return 0;
-} \ No newline at end of file
+}