summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorParadox924X <Paradox924X@54d463be-8e91-2dee-dedb-b68131a5f0ec>2010-12-07 18:38:03 +0000
committerParadox924X <Paradox924X@54d463be-8e91-2dee-dedb-b68131a5f0ec>2010-12-07 18:38:03 +0000
commit663c9c7ce25d3df3749c55c28af162c46015bc92 (patch)
tree29acf07133e1b5b1bc055481c5667b4133e740cf /src/common
parent53daf01b4b07ce131c79fc784220ba6826e70d16 (diff)
downloadhercules-663c9c7ce25d3df3749c55c28af162c46015bc92.tar.gz
hercules-663c9c7ce25d3df3749c55c28af162c46015bc92.tar.bz2
hercules-663c9c7ce25d3df3749c55c28af162c46015bc92.tar.xz
hercules-663c9c7ce25d3df3749c55c28af162c46015bc92.zip
Changed almost all instances of sprintf() to snprintf().
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14563 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/common')
-rw-r--r--src/common/grfio.c14
-rw-r--r--src/common/lock.c6
-rw-r--r--src/common/malloc.c6
-rw-r--r--src/common/md5calc.c2
-rw-r--r--src/common/plugins.c2
-rw-r--r--src/common/utils.c4
6 files changed, 17 insertions, 17 deletions
diff --git a/src/common/grfio.c b/src/common/grfio.c
index fe94e0803..82bf57bf6 100644
--- a/src/common/grfio.c
+++ b/src/common/grfio.c
@@ -398,7 +398,7 @@ int grfio_size(char* fname)
FILELIST lentry;
struct stat st;
- sprintf(lfname, "%s%s", data_dir, fname);
+ snprintf(lfname, sizeof lfname, "%s%s", data_dir, fname);
for (p = &lfname[0]; *p != 0; p++)
if (*p=='\\') *p = '/';
@@ -431,7 +431,7 @@ void* grfio_reads(char* fname, int* size)
char lfname[256], *p;
FILELIST lentry;
- sprintf(lfname, "%s%s", data_dir, fname);
+ snprintf(lfname, sizeof lfname, "%s%s", data_dir, fname);
for (p = &lfname[0]; *p != 0; p++)
if (*p == '\\') *p = '/';
@@ -694,7 +694,7 @@ static void grfio_resourcecheck(void)
int i = 0;
// read resnametable from data directory and return if successful
- sprintf(restable, "%sdata\\resnametable.txt", data_dir);
+ snprintf(restable, sizeof restable, "%sdata\\resnametable.txt", data_dir);
for (ptr = &restable[0]; *ptr != 0; ptr++)
if (*ptr == '\\') *ptr = '/';
@@ -706,8 +706,8 @@ static void grfio_resourcecheck(void)
// we only need the maps' GAT and RSW files
(strstr(w2, ".gat") || strstr(w2, ".rsw")))
{
- sprintf(src, "data\\%s", w1);
- sprintf(dst, "data\\%s", w2);
+ snprintf(src, sizeof src, "data\\%s", w1);
+ snprintf(dst, sizeof dst, "data\\%s", w2);
entry = filelist_find(dst);
// create new entries reusing the original's info
if (entry != NULL) {
@@ -735,8 +735,8 @@ static void grfio_resourcecheck(void)
if (sscanf(ptr, "%[^#]#%[^#]#", w1, w2) == 2 &&
(strstr(w2, ".gat") || strstr(w2, ".rsw")))
{
- sprintf(src, "data\\%s", w1);
- sprintf(dst, "data\\%s", w2);
+ snprintf(src, sizeof src, "data\\%s", w1);
+ snprintf(dst, sizeof dst, "data\\%s", w2);
entry = filelist_find(dst);
if (entry != NULL) {
FILELIST fentry;
diff --git a/src/common/lock.c b/src/common/lock.c
index 643b86e5c..a4bcc7fe0 100644
--- a/src/common/lock.c
+++ b/src/common/lock.c
@@ -25,7 +25,7 @@ FILE* lock_fopen (const char* filename, int *info) {
// 安全なファイル名を得る(手抜き)
do {
- sprintf(newfile, "%s_%04d.tmp", filename, ++no);
+ snprintf(newfile, sizeof newfile, "%s_%04d.tmp", filename, ++no);
} while(exists(newfile) && no < 9999);
*info = no;
return fopen(newfile,"w");
@@ -38,8 +38,8 @@ int lock_fclose (FILE *fp, const char* filename, int *info) {
char oldfile[512];
if (fp != NULL) {
ret = fclose(fp);
- sprintf(newfile, "%s_%04d.tmp", filename, *info);
- sprintf(oldfile, "%s.bak", filename); // old backup file
+ snprintf(newfile, sizeof newfile, "%s_%04d.tmp", filename, *info);
+ snprintf(oldfile, sizeof oldfile, "%s.bak", filename); // old backup file
if (exists(oldfile)) remove(oldfile); // remove backup file if it already exists
rename (filename, oldfile); // backup our older data instead of deleting it
diff --git a/src/common/malloc.c b/src/common/malloc.c
index b566e689f..57300c18f 100644
--- a/src/common/malloc.c
+++ b/src/common/malloc.c
@@ -602,7 +602,7 @@ static void memmgr_final (void)
char* ptr = (char *)head + sizeof(struct unit_head) - sizeof(long);
#ifdef LOG_MEMMGR
char buf[1024];
- sprintf (buf,
+ snprintf (buf, sizeof buf,
"%04d : %s line %d size %lu address 0x%p\n", ++count,
head->file, head->line, (unsigned long)head->size, ptr);
memmgr_log (buf);
@@ -619,7 +619,7 @@ static void memmgr_final (void)
struct unit_head_large *large2;
#ifdef LOG_MEMMGR
char buf[1024];
- sprintf (buf,
+ snprintf (buf, sizeof buf,
"%04d : %s line %d size %lu address 0x%p\n", ++count,
large->unit_head.file, large->unit_head.line, (unsigned long)large->size, &large->unit_head.checksum);
memmgr_log (buf);
@@ -642,7 +642,7 @@ static void memmgr_final (void)
static void memmgr_init (void)
{
#ifdef LOG_MEMMGR
- sprintf(memmer_logfile, "log/%s.leaks", SERVER_NAME);
+ snprintf(memmer_logfile, sizeof memmer_logfile, "log/%s.leaks", SERVER_NAME);
ShowStatus("Memory manager initialised: "CL_WHITE"%s"CL_RESET"\n", memmer_logfile);
memset(hash_unfill, 0, sizeof(hash_unfill));
#endif /* LOG_MEMMGR */
diff --git a/src/common/md5calc.c b/src/common/md5calc.c
index 2178739d6..08ad09ee1 100644
--- a/src/common/md5calc.c
+++ b/src/common/md5calc.c
@@ -222,7 +222,7 @@ void MD5_String(const char * string, char * output)
unsigned char digest[16];
MD5_String2binary(string,digest);
- sprintf(output, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
+ snprintf(output, sizeof output, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
digest[ 0], digest[ 1], digest[ 2], digest[ 3],
digest[ 4], digest[ 5], digest[ 6], digest[ 7],
digest[ 8], digest[ 9], digest[10], digest[11],
diff --git a/src/common/plugins.c b/src/common/plugins.c
index 2d81548a1..614ac3c3a 100644
--- a/src/common/plugins.c
+++ b/src/common/plugins.c
@@ -320,7 +320,7 @@ static int plugins_config_read(const char *cfgName)
auto_search = atoi(w2);
} else if( strcmpi(w1,"plugin") == 0 ){
char filename[128];
- sprintf(filename, "plugins/%s%s", w2, DLL_EXT);
+ snprintf(filename, sizeof filename, "plugins/%s%s", w2, DLL_EXT);
plugin_load(filename);
} else if( strcmpi(w1,"import") == 0 )
plugins_config_read(w2);
diff --git a/src/common/utils.c b/src/common/utils.c
index 12123784f..a95072f7d 100644
--- a/src/common/utils.c
+++ b/src/common/utils.c
@@ -104,7 +104,7 @@ void findfile(const char *p, const char *pat, void (func)(const char*))
if (strcmp(FindFileData.cFileName, "..") == 0)
continue;
- sprintf(tmppath,"%s%c%s",path,PATHSEP,FindFileData.cFileName);
+ snprintf(tmppath,sizeof tmppath,"%s%c%s",path,PATHSEP,FindFileData.cFileName);
if (FindFileData.cFileName && strstr(FindFileData.cFileName, pattern)) {
func( tmppath );
@@ -166,7 +166,7 @@ void findfile(const char *p, const char *pat, void (func)(const char*))
if (strcmp(entry->d_name, "..") == 0)
continue;
- sprintf(tmppath,"%s%c%s",path, PATHSEP, entry->d_name);
+ snprintf(tmppath,sizeof tmppath,"%s%c%s",path, PATHSEP, entry->d_name);
// check if the pattern matchs.
if (entry->d_name && strstr(entry->d_name, pattern)) {