comparison libpurple/prefs.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 3687049b4faf
children 32a707746454
comparison
equal deleted inserted replaced
26884:88c87a40a738 26885:8290e36a5a73
116 static void 116 static void
117 pref_to_xmlnode(xmlnode *parent, struct purple_pref *pref) 117 pref_to_xmlnode(xmlnode *parent, struct purple_pref *pref)
118 { 118 {
119 xmlnode *node, *childnode; 119 xmlnode *node, *childnode;
120 struct purple_pref *child; 120 struct purple_pref *child;
121 char buf[20]; 121 char buf[21];
122 GList *cur; 122 GList *cur;
123 123
124 /* Create a new node */ 124 /* Create a new node */
125 node = xmlnode_new_child(parent, "pref"); 125 node = xmlnode_new_child(parent, "pref");
126 xmlnode_set_attrib(node, "name", pref->name); 126 xmlnode_set_attrib(node, "name", pref->name);
127 127
128 /* Set the type of this node (if type == PURPLE_PREF_NONE then do nothing) */ 128 /* Set the type of this node (if type == PURPLE_PREF_NONE then do nothing) */
129 if (pref->type == PURPLE_PREF_INT) { 129 if (pref->type == PURPLE_PREF_INT) {
130 xmlnode_set_attrib(node, "type", "int"); 130 xmlnode_set_attrib(node, "type", "int");
131 snprintf(buf, sizeof(buf), "%d", pref->value.integer); 131 g_snprintf(buf, sizeof(buf), "%d", pref->value.integer);
132 xmlnode_set_attrib(node, "value", buf); 132 xmlnode_set_attrib(node, "value", buf);
133 } 133 }
134 else if (pref->type == PURPLE_PREF_STRING) { 134 else if (pref->type == PURPLE_PREF_STRING) {
135 xmlnode_set_attrib(node, "type", "string"); 135 xmlnode_set_attrib(node, "type", "string");
136 xmlnode_set_attrib(node, "value", pref->value.string ? pref->value.string : ""); 136 xmlnode_set_attrib(node, "value", pref->value.string ? pref->value.string : "");
159 g_free(encoded); 159 g_free(encoded);
160 } 160 }
161 } 161 }
162 else if (pref->type == PURPLE_PREF_BOOLEAN) { 162 else if (pref->type == PURPLE_PREF_BOOLEAN) {
163 xmlnode_set_attrib(node, "type", "bool"); 163 xmlnode_set_attrib(node, "type", "bool");
164 snprintf(buf, sizeof(buf), "%d", pref->value.boolean); 164 g_snprintf(buf, sizeof(buf), "%d", pref->value.boolean);
165 xmlnode_set_attrib(node, "value", buf); 165 xmlnode_set_attrib(node, "value", buf);
166 } 166 }
167 167
168 /* All My Children */ 168 /* All My Children */
169 for (child = pref->first_child; child != NULL; child = child->sibling) 169 for (child = pref->first_child; child != NULL; child = child->sibling)