diff --git a/engine/common/cmd.c b/engine/common/cmd.c index 34e8b1acb..d97cdad0d 100644 --- a/engine/common/cmd.c +++ b/engine/common/cmd.c @@ -762,7 +762,7 @@ static void Cmd_Exec_f (void) f = fs_manifest->mainconfig; if (!*f) f = "config"; - snprintf(name, sizeof(name)-5, "configs/%s", f); + Q_snprintfz(name, sizeof(name)-5, "configs/%s", f); COM_DefaultExtension(name, ".cfg", sizeof(name)); } else @@ -1190,7 +1190,7 @@ static void Cmd_Alias_f (void) // check for overlap with a command if (Cmd_Exists (s)) { //commands always take precedence over aliases (so mods can't clobber 'quit' etc), so creating an alias with one of these names is stupid. always try to rename them. - if (Cmd_IsInsecure() && snprintf(cmd, sizeof(cmd), "%s_a", s) < sizeof(cmd)) + if (Cmd_IsInsecure() && Q_snprintfz(cmd, sizeof(cmd), "%s_a", s) < sizeof(cmd)) { if (Cmd_Exists (cmd)) { @@ -1210,7 +1210,7 @@ static void Cmd_Alias_f (void) { //aliases take precedence over cvars (while cvars can be set via 'set'), so user's choice. if (Cvar_FindVar (s)) { - if (Cmd_IsInsecure() && snprintf(cmd, sizeof(cmd), "%s_a", s) < sizeof(cmd)) + if (Cmd_IsInsecure() && Q_snprintfz(cmd, sizeof(cmd), "%s_a", s) < sizeof(cmd)) { Con_Printf (S_COLOR_RED"alias %s: renamed to %s due to cvar conflict\n", s, cmd); s = cmd; @@ -4147,7 +4147,7 @@ static void Cmd_WriteConfig_f(void) else if (!Q_strcasecmp(Cmd_Argv(0), "saveconfig")) { //dpcompat: this variation allows writing to any path. at least force the extension. - snprintf(fname, sizeof(fname), "%s", filename); + Q_snprintfz(fname, sizeof(fname), "%s", filename); COM_RequireExtension(fname, ".cfg", sizeof(fname)); if (Cmd_IsInsecure() && strncmp(fname, "data/", 5)) @@ -4175,7 +4175,7 @@ static void Cmd_WriteConfig_f(void) Con_Printf (CON_ERROR "Couldn't write config %s\n",filename); return; } - snprintf(fname, sizeof(fname), "configs/%s", filename); + Q_snprintfz(fname, sizeof(fname), "configs/%s", filename); COM_DefaultExtension(fname, ".cfg", sizeof(fname)); FS_NativePath(fname, FS_BASEGAMEONLY, sysname, sizeof(sysname)); diff --git a/engine/common/fs.c b/engine/common/fs.c index 0f89e75c7..a88f31306 100644 --- a/engine/common/fs.c +++ b/engine/common/fs.c @@ -2308,7 +2308,7 @@ qboolean FS_NativePath(const char *fname, enum fs_relative relativeto, char *out if (relativeto == FS_SYSTEM) { //system is already the native path. we can just pass it through. perhaps we should clean it up first however, although that's just making sure all \ are / - snprintf(out, outlen, "%s", fname); + Q_snprintfz(out, outlen, "%s", fname); for (; *out; out++) { @@ -2337,36 +2337,36 @@ qboolean FS_NativePath(const char *fname, enum fs_relative relativeto, char *out case FS_GAME: //this is really for diagnostic type stuff... if (FS_FLocateFile(fname, FSLF_IFFOUND, &loc)) { - nlen = snprintf(out, outlen, "%s/%s", loc.search->logicalpath, fname); + nlen = Q_snprintfz(out, outlen, "%s/%s", loc.search->logicalpath, fname); break; } //fallthrough case FS_GAMEONLY: if (com_homepathenabled) - nlen = snprintf(out, outlen, "%s%s/%s", com_homepath, gamedirfile, fname); + nlen = Q_snprintfz(out, outlen, "%s%s/%s", com_homepath, gamedirfile, fname); else - nlen = snprintf(out, outlen, "%s%s/%s", com_gamepath, gamedirfile, fname); + nlen = Q_snprintfz(out, outlen, "%s%s/%s", com_gamepath, gamedirfile, fname); break; case FS_LIBRARYPATH: #ifdef FTE_LIBRARY_PATH - nlen = snprintf(out, outlen, STRINGIFY(FTE_LIBRARY_PATH)"/%s", fname); + nlen = Q_snprintfz(out, outlen, STRINGIFY(FTE_LIBRARY_PATH)"/%s", fname); break; #else return false; #endif case FS_BINARYPATH: if (host_parms.binarydir && *host_parms.binarydir) - nlen = snprintf(out, outlen, "%s%s", host_parms.binarydir, fname); + nlen = Q_snprintfz(out, outlen, "%s%s", host_parms.binarydir, fname); else - nlen = snprintf(out, outlen, "%s%s", host_parms.basedir, fname); + nlen = Q_snprintfz(out, outlen, "%s%s", host_parms.basedir, fname); break; case FS_ROOT: if (com_installer) return false; if (com_homepathenabled) - nlen = snprintf(out, outlen, "%s%s", com_homepath, fname); + nlen = Q_snprintfz(out, outlen, "%s%s", com_homepath, fname); else - nlen = snprintf(out, outlen, "%s%s", com_gamepath, fname); + nlen = Q_snprintfz(out, outlen, "%s%s", com_gamepath, fname); break; case FS_BASEGAMEONLY: // fte/ @@ -2383,9 +2383,9 @@ qboolean FS_NativePath(const char *fname, enum fs_relative relativeto, char *out if (!last) return false; //eep? if (com_homepathenabled) - nlen = snprintf(out, outlen, "%s%s/%s", com_homepath, last, fname); + nlen = Q_snprintfz(out, outlen, "%s%s/%s", com_homepath, last, fname); else - nlen = snprintf(out, outlen, "%s%s/%s", com_gamepath, last, fname); + nlen = Q_snprintfz(out, outlen, "%s%s/%s", com_gamepath, last, fname); break; case FS_PUBGAMEONLY: // $gamedir/ or qw/ but not fte/ last = NULL; @@ -2406,9 +2406,9 @@ qboolean FS_NativePath(const char *fname, enum fs_relative relativeto, char *out if (!last) return false; //eep? if (com_homepathenabled) - nlen = snprintf(out, outlen, "%s%s/%s", com_homepath, last, fname); + nlen = Q_snprintfz(out, outlen, "%s%s/%s", com_homepath, last, fname); else - nlen = snprintf(out, outlen, "%s%s/%s", com_gamepath, last, fname); + nlen = Q_snprintfz(out, outlen, "%s%s/%s", com_gamepath, last, fname); break; case FS_PUBBASEGAMEONLY: // qw/ (fixme: should be the last non-private basedir) last = NULL; @@ -2424,9 +2424,9 @@ qboolean FS_NativePath(const char *fname, enum fs_relative relativeto, char *out if (!last) return false; //eep? if (com_homepathenabled) - nlen = snprintf(out, outlen, "%s%s/%s", com_homepath, last, fname); + nlen = Q_snprintfz(out, outlen, "%s%s/%s", com_homepath, last, fname); else - nlen = snprintf(out, outlen, "%s%s/%s", com_gamepath, last, fname); + nlen = Q_snprintfz(out, outlen, "%s%s/%s", com_gamepath, last, fname); break; default: Sys_Error("FS_NativePath case not handled\n"); @@ -3840,9 +3840,10 @@ qboolean FS_Restarted(unsigned int *since) } #ifdef __WIN32 //already assumed to be case insensitive. let the OS keep fixing up the paths itself. -static void FS_FixupFileCase(char *out, size_t outsize, const char *basedir, const char *entry) +static qboolean FS_FixupFileCase(char *out, size_t outsize, const char *basedir, const char *entry, qboolean isdir) { Q_snprintfz(out, outsize, "%s%s", basedir, entry); + return true; } #else struct fixupcase_s