Mercurial > pidgin
comparison libpurple/blist.c @ 26885:8290e36a5a73
A patch from Scott Wolchok to replace snprintf() with g_snprintf() and
increase the size of some buffers to be able to fit -2^63.
I don't think the snprintf() -> g_snprintf() changes do anything with glibc,
but there's no harm in using the glib function to guarantee NUL termination.
Fixes #8974
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Sat, 16 May 2009 19:58:40 +0000 |
parents | 73eeb91911f3 |
children | c59918579c3a |
comparison
equal
deleted
inserted
replaced
26884:88c87a40a738 | 26885:8290e36a5a73 |
---|---|
123 value_to_xmlnode(gpointer key, gpointer hvalue, gpointer user_data) | 123 value_to_xmlnode(gpointer key, gpointer hvalue, gpointer user_data) |
124 { | 124 { |
125 const char *name; | 125 const char *name; |
126 PurpleValue *value; | 126 PurpleValue *value; |
127 xmlnode *node, *child; | 127 xmlnode *node, *child; |
128 char buf[20]; | 128 char buf[21]; |
129 | 129 |
130 name = (const char *)key; | 130 name = (const char *)key; |
131 value = (PurpleValue *)hvalue; | 131 value = (PurpleValue *)hvalue; |
132 node = (xmlnode *)user_data; | 132 node = (xmlnode *)user_data; |
133 | 133 |
136 child = xmlnode_new_child(node, "setting"); | 136 child = xmlnode_new_child(node, "setting"); |
137 xmlnode_set_attrib(child, "name", name); | 137 xmlnode_set_attrib(child, "name", name); |
138 | 138 |
139 if (purple_value_get_type(value) == PURPLE_TYPE_INT) { | 139 if (purple_value_get_type(value) == PURPLE_TYPE_INT) { |
140 xmlnode_set_attrib(child, "type", "int"); | 140 xmlnode_set_attrib(child, "type", "int"); |
141 snprintf(buf, sizeof(buf), "%d", purple_value_get_int(value)); | 141 g_snprintf(buf, sizeof(buf), "%d", purple_value_get_int(value)); |
142 xmlnode_insert_data(child, buf, -1); | 142 xmlnode_insert_data(child, buf, -1); |
143 } | 143 } |
144 else if (purple_value_get_type(value) == PURPLE_TYPE_STRING) { | 144 else if (purple_value_get_type(value) == PURPLE_TYPE_STRING) { |
145 xmlnode_set_attrib(child, "type", "string"); | 145 xmlnode_set_attrib(child, "type", "string"); |
146 xmlnode_insert_data(child, purple_value_get_string(value), -1); | 146 xmlnode_insert_data(child, purple_value_get_string(value), -1); |
147 } | 147 } |
148 else if (purple_value_get_type(value) == PURPLE_TYPE_BOOLEAN) { | 148 else if (purple_value_get_type(value) == PURPLE_TYPE_BOOLEAN) { |
149 xmlnode_set_attrib(child, "type", "bool"); | 149 xmlnode_set_attrib(child, "type", "bool"); |
150 snprintf(buf, sizeof(buf), "%d", purple_value_get_boolean(value)); | 150 g_snprintf(buf, sizeof(buf), "%d", purple_value_get_boolean(value)); |
151 xmlnode_insert_data(child, buf, -1); | 151 xmlnode_insert_data(child, buf, -1); |
152 } | 152 } |
153 } | 153 } |
154 | 154 |
155 static void | 155 static void |
301 char buf[10]; | 301 char buf[10]; |
302 | 302 |
303 node = xmlnode_new("account"); | 303 node = xmlnode_new("account"); |
304 xmlnode_set_attrib(node, "proto", purple_account_get_protocol_id(account)); | 304 xmlnode_set_attrib(node, "proto", purple_account_get_protocol_id(account)); |
305 xmlnode_set_attrib(node, "name", purple_account_get_username(account)); | 305 xmlnode_set_attrib(node, "name", purple_account_get_username(account)); |
306 snprintf(buf, sizeof(buf), "%d", account->perm_deny); | 306 g_snprintf(buf, sizeof(buf), "%d", account->perm_deny); |
307 xmlnode_set_attrib(node, "mode", buf); | 307 xmlnode_set_attrib(node, "mode", buf); |
308 | 308 |
309 for (cur = account->permit; cur; cur = cur->next) | 309 for (cur = account->permit; cur; cur = cur->next) |
310 { | 310 { |
311 child = xmlnode_new_child(node, "permit"); | 311 child = xmlnode_new_child(node, "permit"); |