diff libpurple/account.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 76a1598ecf1c
children b98d066df628 627d23bfdb05
line wrap: on
line diff
--- a/libpurple/account.c	Sat May 16 19:06:53 2009 +0000
+++ b/libpurple/account.c	Sat May 16 19:58:40 2009 +0000
@@ -99,7 +99,7 @@
 	const char *name;
 	PurpleAccountSetting *setting;
 	xmlnode *node, *child;
-	char buf[20];
+	char buf[21];
 
 	name    = (const char *)key;
 	setting = (PurpleAccountSetting *)value;
@@ -110,7 +110,7 @@
 
 	if (setting->type == PURPLE_PREF_INT) {
 		xmlnode_set_attrib(child, "type", "int");
-		snprintf(buf, sizeof(buf), "%d", setting->value.integer);
+		g_snprintf(buf, sizeof(buf), "%d", setting->value.integer);
 		xmlnode_insert_data(child, buf, -1);
 	}
 	else if (setting->type == PURPLE_PREF_STRING && setting->value.string != NULL) {
@@ -119,7 +119,7 @@
 	}
 	else if (setting->type == PURPLE_PREF_BOOLEAN) {
 		xmlnode_set_attrib(child, "type", "bool");
-		snprintf(buf, sizeof(buf), "%d", setting->value.boolean);
+		g_snprintf(buf, sizeof(buf), "%d", setting->value.boolean);
 		xmlnode_insert_data(child, buf, -1);
 	}
 }
@@ -281,7 +281,7 @@
 	PurpleProxyType proxy_type;
 	const char *value;
 	int int_value;
-	char buf[20];
+	char buf[21];
 
 	proxy_type = purple_proxy_info_get_type(proxy_info);
 
@@ -304,7 +304,7 @@
 
 	if ((int_value = purple_proxy_info_get_port(proxy_info)) != 0)
 	{
-		snprintf(buf, sizeof(buf), "%d", int_value);
+		g_snprintf(buf, sizeof(buf), "%d", int_value);
 		child = xmlnode_new_child(node, "port");
 		xmlnode_insert_data(child, buf, -1);
 	}
@@ -342,7 +342,7 @@
 		return node;
 
 	child = xmlnode_new_child(node, "type");
-	snprintf(type_str, sizeof(type_str), "%u", err->type);
+	g_snprintf(type_str, sizeof(type_str), "%u", err->type);
 	xmlnode_insert_data(child, type_str, -1);
 
 	child = xmlnode_new_child(node, "description");