Replaced sprintf() calls with snprintf().
This commit is contained in:
parent
e4c035a99f
commit
f8ed5c6f7e
|
@ -13,10 +13,11 @@
|
|||
|
||||
|
||||
|
||||
static char *cvtToDependent(const char *prepend, const char *path, char *buf)
|
||||
static char *cvtToDependent(const char *prepend, const char *path,
|
||||
char *buf, const size_t buflen)
|
||||
{
|
||||
BAIL_IF(buf == NULL, PHYSFS_ERR_OUT_OF_MEMORY, NULL);
|
||||
sprintf(buf, "%s%s", prepend ? prepend : "", path);
|
||||
snprintf(buf, buflen, "%s%s", prepend ? prepend : "", path);
|
||||
|
||||
if (__PHYSFS_platformDirSeparator != '/')
|
||||
{
|
||||
|
@ -31,7 +32,7 @@ static char *cvtToDependent(const char *prepend, const char *path, char *buf)
|
|||
|
||||
#define CVT_TO_DEPENDENT(buf, pre, dir) { \
|
||||
const size_t len = ((pre) ? strlen((char *) pre) : 0) + strlen(dir) + 1; \
|
||||
buf = cvtToDependent((char*)pre,dir,(char*)__PHYSFS_smallAlloc(len)); \
|
||||
buf = cvtToDependent((char*)pre,dir,(char*)__PHYSFS_smallAlloc(len),len); \
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
*/
|
||||
|
||||
/* !!! FIXME: ERR_PAST_EOF shouldn't trigger for reads. Just return zero. */
|
||||
/* !!! FIXME: use snprintf(), not sprintf(). */
|
||||
|
||||
#define __PHYSICSFS_INTERNAL__
|
||||
#include "physfs_internal.h"
|
||||
|
@ -1831,7 +1830,7 @@ static void setSaneCfgAddPath(const char *i, const size_t l, const char *dirsep,
|
|||
char *str = (char *) __PHYSFS_smallAlloc(allocsize);
|
||||
if (str != NULL)
|
||||
{
|
||||
sprintf(str, "%s%s%s", d, dirsep, i);
|
||||
snprintf(str, allocsize, "%s%s%s", d, dirsep, i);
|
||||
PHYSFS_mount(str, NULL, archivesFirst == 0);
|
||||
__PHYSFS_smallFree(str);
|
||||
} /* if */
|
||||
|
@ -2272,7 +2271,7 @@ static void enumCallbackFilterSymLinks(void *_data, const char *origdir,
|
|||
const DirHandle *dh = data->dirhandle;
|
||||
PHYSFS_Stat statbuf;
|
||||
|
||||
sprintf(path, "%s%s%s", trimmedDir, *trimmedDir ? "/" : "", fname);
|
||||
snprintf(path, slen, "%s%s%s", trimmedDir, *trimmedDir ? "/" : "", fname);
|
||||
if (dh->funcs->stat(dh->opaque, path, &statbuf))
|
||||
{
|
||||
/* Pass it on to the application if it's not a symlink. */
|
||||
|
|
|
@ -413,7 +413,7 @@ char *__PHYSFS_platformCalcPrefDir(const char *org, const char *app)
|
|||
BAIL(PHYSFS_ERR_OUT_OF_MEMORY, NULL);
|
||||
} /* if */
|
||||
|
||||
sprintf(retval, "%s\\%s\\%s\\", utf8, org, app);
|
||||
snprintf(retval, len, "%s\\%s\\%s\\", utf8, org, app);
|
||||
allocator.Free(utf8);
|
||||
return retval;
|
||||
} /* __PHYSFS_platformCalcPrefDir */
|
||||
|
|
Loading…
Reference in New Issue