diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/command.h | 6 | ||||
-rw-r--r-- | src/dxvk.c | 13 | ||||
-rw-r--r-- | src/tar.c | 2 |
3 files changed, 12 insertions, 9 deletions
diff --git a/src/command.h b/src/command.h index 54ce16f..7460d59 100644 --- a/src/command.h +++ b/src/command.h @@ -65,9 +65,9 @@ \ for (unsigned long i = 0; i < ARRAY_LEN(GROUP##_flags); ++i) \ { \ - if (GROUP##_flags[i].variant & SINGLE && argv[j][1] == GROUP##_flags[i].name[0] || \ - GROUP##_flags[i].variant & DOUBLE && argv[j][1] == '-' \ - && !strcmp(GROUP##_flags[i].name, argv[j]+2)) \ + if ((GROUP##_flags[i].variant & SINGLE && argv[j][1] == GROUP##_flags[i].name[0]) || \ + (GROUP##_flags[i].variant & DOUBLE && argv[j][1] == '-' \ + && !strcmp(GROUP##_flags[i].name, argv[j]+2))) \ { \ return GROUP##_flags[i].func(0, NULL); \ } \ @@ -182,11 +182,14 @@ COMMAND(dxvk, install) { // quote the dxvkpath so whitespace won't cause trouble { - char dxvkpathcpy[PATH_MAX] = {0}; - strncat(dxvkpathcpy, "\"", sizeof(dxvkpathcpy) - strlen(dxvkpathcpy) - 1); - strncat(dxvkpathcpy, dxvkpath, sizeof(dxvkpathcpy) - strlen(dxvkpathcpy) - 1); - strncat(dxvkpathcpy, "\"", sizeof(dxvkpathcpy) - strlen(dxvkpathcpy) - 1); - strncpy(dxvkpath, dxvkpathcpy, sizeof(dxvkpathcpy)); + size_t size = strlen(dxvkpath) + 1; + if (size > sizeof(dxvkpath)) size = sizeof(dxvkpath); + + memmove(dxvkpath+1, dxvkpath, size - 1); + dxvkpath[0] = '"'; + + strncat(dxvkpath, "\"", sizeof(dxvkpath) - size); + } strncat(dxvkpath, " install", sizeof(dxvkpath) - strlen(dxvkpath) - 1); @@ -108,5 +108,5 @@ void extract(const struct MemoryStruct* tar, const char* outputdir) archive_write_close(ext); archive_write_free(ext); - if (err) chdir(cwd); + if (err) (void)chdir(cwd); } |