summaryrefslogtreecommitdiff
path: root/src/char/char.c
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/char/char.c
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/char/char.c')
-rw-r--r--src/char/char.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/char/char.c b/src/char/char.c
index 91ad7d33d..927e0e8fa 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -358,7 +358,7 @@ int char_log(char *fmt, ...)
else {
time(&raw_time);
strftime(tmpstr, 24, "%d-%m-%Y %H:%M:%S", localtime(&raw_time));
- sprintf(tmpstr + 19, ": %s", fmt);
+ snprintf(tmpstr + 19, sizeof (tmpstr + 19), ": %s", fmt);
vfprintf(logfp, tmpstr, ap);
}
fclose(logfp);
@@ -440,11 +440,11 @@ int mmo_friends_list_data_str(char *str, struct mmo_charstatus *p)
{
int i;
char *str_p = str;
- str_p += sprintf(str_p, "%d", p->char_id);
+ str_p += snprintf(str_p, sizeof str_p, "%d", p->char_id);
for (i=0;i<MAX_FRIENDS;i++){
if (p->friends[i].account_id > 0 && p->friends[i].char_id > 0 && p->friends[i].name[0])
- str_p += sprintf(str_p, ",%d,%d,%s", p->friends[i].account_id, p->friends[i].char_id, p->friends[i].name);
+ str_p += snprintf(str_p, sizeof str_p, ",%d,%d,%s", p->friends[i].account_id, p->friends[i].char_id, p->friends[i].name);
}
str_p += '\0';
@@ -460,9 +460,9 @@ int mmo_hotkeys_tostr(char *str, struct mmo_charstatus *p)
#ifdef HOTKEY_SAVING
int i;
char *str_p = str;
- str_p += sprintf(str_p, "%d", p->char_id);
+ str_p += snprintf(str_p, sizeof str_p, "%d", p->char_id);
for (i=0;i<MAX_HOTKEYS;i++)
- str_p += sprintf(str_p, ",%d,%d,%d", p->hotkeys[i].type, p->hotkeys[i].id, p->hotkeys[i].lv);
+ str_p += snprintf(str_p, sizeof str_p, ",%d,%d,%d", p->hotkeys[i].type, p->hotkeys[i].id, p->hotkeys[i].lv);
str_p += '\0';
#endif
@@ -477,7 +477,7 @@ int mmo_char_tostr(char *str, struct mmo_charstatus *p, struct global_reg *reg,
int i,j;
char *str_p = str;
- str_p += sprintf(str_p,
+ str_p += snprintf(str_p, sizeof str_p,
"%d\t%d,%d\t%s\t%d,%d,%d\t%u,%u,%d" //Up to Zeny field
"\t%d,%d,%d,%d\t%d,%d,%d,%d,%d,%d\t%d,%d" //Up to Skill Point
"\t%d,%d,%d\t%d,%d,%d,%d" //Up to hom id
@@ -499,41 +499,41 @@ int mmo_char_tostr(char *str, struct mmo_charstatus *p, struct global_reg *reg,
p->partner_id,p->father,p->mother,p->child,p->fame);
for(i = 0; i < MAX_MEMOPOINTS; i++)
if (p->memo_point[i].map) {
- str_p += sprintf(str_p, "%d,%d,%d ", p->memo_point[i].map, p->memo_point[i].x, p->memo_point[i].y);
+ str_p += snprintf(str_p, sizeof str_p, "%d,%d,%d ", p->memo_point[i].map, p->memo_point[i].x, p->memo_point[i].y);
}
*(str_p++) = '\t';
for(i = 0; i < MAX_INVENTORY; i++)
if (p->inventory[i].nameid) {
- str_p += sprintf(str_p,"%d,%d,%d,%d,%d,%d,%d",
+ str_p += snprintf(str_p,sizeof str_p,"%d,%d,%d,%d,%d,%d,%d",
p->inventory[i].id,p->inventory[i].nameid,p->inventory[i].amount,p->inventory[i].equip,
p->inventory[i].identify,p->inventory[i].refine,p->inventory[i].attribute);
for(j=0; j<MAX_SLOTS; j++)
- str_p += sprintf(str_p,",%d",p->inventory[i].card[j]);
- str_p += sprintf(str_p," ");
+ str_p += snprintf(str_p,sizeof str_p,",%d",p->inventory[i].card[j]);
+ str_p += snprintf(str_p,sizeof str_p," ");
}
*(str_p++) = '\t';
for(i = 0; i < MAX_CART; i++)
if (p->cart[i].nameid) {
- str_p += sprintf(str_p,"%d,%d,%d,%d,%d,%d,%d",
+ str_p += snprintf(str_p,sizeof str_p,"%d,%d,%d,%d,%d,%d,%d",
p->cart[i].id,p->cart[i].nameid,p->cart[i].amount,p->cart[i].equip,
p->cart[i].identify,p->cart[i].refine,p->cart[i].attribute);
for(j=0; j<MAX_SLOTS; j++)
- str_p += sprintf(str_p,",%d",p->cart[i].card[j]);
- str_p += sprintf(str_p," ");
+ str_p += snprintf(str_p,sizeof str_p,",%d",p->cart[i].card[j]);
+ str_p += snprintf(str_p,sizeof str_p," ");
}
*(str_p++) = '\t';
for(i = 0; i < MAX_SKILL; i++)
if (p->skill[i].id && p->skill[i].flag != 1) {
- str_p += sprintf(str_p, "%d,%d ", p->skill[i].id, (p->skill[i].flag == 0) ? p->skill[i].lv : p->skill[i].flag-2);
+ str_p += snprintf(str_p, sizeof str_p, "%d,%d ", p->skill[i].id, (p->skill[i].flag == 0) ? p->skill[i].lv : p->skill[i].flag-2);
}
*(str_p++) = '\t';
for(i = 0; i < reg_num; i++)
if (reg[i].str[0])
- str_p += sprintf(str_p, "%s,%s ", reg[i].str, reg[i].value);
+ str_p += snprintf(str_p, sizeof str_p, "%s,%s ", reg[i].str, reg[i].value);
*(str_p++) = '\t';
*str_p = '\0';
@@ -1496,7 +1496,7 @@ void create_online_files(void)
// get time
time(&time_server); // get time in seconds since 1/1/1970
datetime = localtime(&time_server); // convert seconds in structure
- strftime(temp, sizeof(temp), "%d %b %Y %X", datetime); // like sprintf, but only for date/time (05 dec 2003 15:12:52)
+ strftime(temp, sizeof(temp), "%d %b %Y %X", datetime); // like snprintf, but only for date/time (05 dec 2003 15:12:52)
// write heading
fprintf(fp2, "<HTML>\n");
fprintf(fp2, " <META http-equiv=\"Refresh\" content=\"%d\">\n", online_refresh_html); // update on client explorer every x seconds