diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2009-08-26 14:25:20 +0200 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2009-08-26 14:25:20 +0200 |
commit | 4e80effe0ec3edcef9e2f240864eacab9cdbb035 (patch) | |
tree | 16a747db7165db3e6cd6f4e0056b7f12cace7db5 | |
parent | 2ecd826602bd7a83aac609fbc65c32544062f426 (diff) |
Replace sprintf with snprintf
-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; |