diff options
-rw-r--r-- | config.c | 4 | ||||
-rw-r--r-- | export_xml.c | 8 |
2 files changed, 6 insertions, 6 deletions
@@ -57,13 +57,13 @@ int cfg_init() { if(!config_setting_lookup_string(channel_setting, "name", &name)) { char *sname; sname = malloc(sizeof(char) * 16); - sprintf(sname, "channel #%d", i+1); + snprintf(sname, 16, "channel #%d", i+1); name = sname; } if(!config_setting_lookup_string(channel_setting, "xmlpath", &xmlpath)) { /* Index-based filename if xmlpath isn't set. */ char temp[0xf]; - sprintf(temp, "%d.xml", i); + snprintf(temp, 0xf, "%d.xml", i); xmlpath = strdup(temp); } struct channel_t *channel; diff --git a/export_xml.c b/export_xml.c index ffdeffc..4485f9d 100644 --- a/export_xml.c +++ b/export_xml.c @@ -24,7 +24,7 @@ int export_xml(struct channel_t *channel, struct user_t *users) { xmlNodePtr hour_node = xmlNewChild(lines_node, NULL, "hour", NULL); for(int q = 0; q < 4; q++) { char s[0xf]; - sprintf(s, "%d", channel->hours[h*4 + q]); + snprintf(s, 0xf, "%d", channel->hours[h*4 + q]); xmlNewChild(hour_node, NULL, "quarter", s); } } @@ -39,7 +39,7 @@ int export_xml(struct channel_t *channel, struct user_t *users) { xmlNodePtr user_node = xmlNewChild(users_node, NULL, "user", NULL); xmlNewChild(user_node, NULL, "nick", user->nick); - sprintf(s, "%d", user->words); + snprintf(s, 0xf, "%d", user->words); xmlNewChild(user_node, NULL, "words", s); /* Add lines for this user. */ @@ -47,7 +47,7 @@ int export_xml(struct channel_t *channel, struct user_t *users) { for(int h = 0; h < 24; h++) { xmlNodePtr hour_node = xmlNewChild(lines_node, NULL, "hour", NULL); for(int q = 0; q < 4; q++) { - sprintf(s, "%d", user->lines[h*4 + q]); + snprintf(s, 0xf, "%d", user->lines[h*4 + q]); xmlNewChild(hour_node, NULL, "quarter", s); } } @@ -64,7 +64,7 @@ int export_xml(struct channel_t *channel, struct user_t *users) { xmlNodePtr word_node = xmlNewChild(words_node, NULL, "word", NULL); xmlNewChild(word_node, NULL, "name", word->name); - sprintf(s, "%d", word->count); + snprintf(s, 0xf, "%d", word->count); xmlNewChild(word_node, NULL, "count", s); word = word->next; |