Mercurial > pidgin
changeset 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 | 88c87a40a738 |
children | 1788bc69ba7b |
files | libpurple/account.c libpurple/blist.c libpurple/dnsquery.c libpurple/network.c libpurple/prefs.c libpurple/savedstatuses.c libpurple/util.c |
diffstat | 7 files changed, 19 insertions(+), 19 deletions(-) [+] |
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");
--- a/libpurple/blist.c Sat May 16 19:06:53 2009 +0000 +++ b/libpurple/blist.c Sat May 16 19:58:40 2009 +0000 @@ -125,7 +125,7 @@ const char *name; PurpleValue *value; xmlnode *node, *child; - char buf[20]; + char buf[21]; name = (const char *)key; value = (PurpleValue *)hvalue; @@ -138,7 +138,7 @@ if (purple_value_get_type(value) == PURPLE_TYPE_INT) { xmlnode_set_attrib(child, "type", "int"); - snprintf(buf, sizeof(buf), "%d", purple_value_get_int(value)); + g_snprintf(buf, sizeof(buf), "%d", purple_value_get_int(value)); xmlnode_insert_data(child, buf, -1); } else if (purple_value_get_type(value) == PURPLE_TYPE_STRING) { @@ -147,7 +147,7 @@ } else if (purple_value_get_type(value) == PURPLE_TYPE_BOOLEAN) { xmlnode_set_attrib(child, "type", "bool"); - snprintf(buf, sizeof(buf), "%d", purple_value_get_boolean(value)); + g_snprintf(buf, sizeof(buf), "%d", purple_value_get_boolean(value)); xmlnode_insert_data(child, buf, -1); } } @@ -303,7 +303,7 @@ node = xmlnode_new("account"); xmlnode_set_attrib(node, "proto", purple_account_get_protocol_id(account)); xmlnode_set_attrib(node, "name", purple_account_get_username(account)); - snprintf(buf, sizeof(buf), "%d", account->perm_deny); + g_snprintf(buf, sizeof(buf), "%d", account->perm_deny); xmlnode_set_attrib(node, "mode", buf); for (cur = account->permit; cur; cur = cur->next)
--- a/libpurple/dnsquery.c Sat May 16 19:06:53 2009 +0000 +++ b/libpurple/dnsquery.c Sat May 16 19:58:40 2009 +0000 @@ -325,7 +325,7 @@ return; already_done = TRUE; ppid = getppid(); - snprintf(s, sizeof(s), "/proc/%d/exe", ppid); + g_snprintf(s, sizeof(s), "/proc/%d/exe", ppid); n = readlink(s, e, sizeof(e)); if(n < 0) return;
--- a/libpurple/network.c Sat May 16 19:06:53 2009 +0000 +++ b/libpurple/network.c Sat May 16 19:58:40 2009 +0000 @@ -303,7 +303,7 @@ /* * Get a list of addresses on this machine. */ - snprintf(serv, sizeof(serv), "%hu", port); + g_snprintf(serv, sizeof(serv), "%hu", port); memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_flags = AI_PASSIVE; hints.ai_family = AF_UNSPEC;
--- a/libpurple/prefs.c Sat May 16 19:06:53 2009 +0000 +++ b/libpurple/prefs.c Sat May 16 19:58:40 2009 +0000 @@ -118,7 +118,7 @@ { xmlnode *node, *childnode; struct purple_pref *child; - char buf[20]; + char buf[21]; GList *cur; /* Create a new node */ @@ -128,7 +128,7 @@ /* Set the type of this node (if type == PURPLE_PREF_NONE then do nothing) */ if (pref->type == PURPLE_PREF_INT) { xmlnode_set_attrib(node, "type", "int"); - snprintf(buf, sizeof(buf), "%d", pref->value.integer); + g_snprintf(buf, sizeof(buf), "%d", pref->value.integer); xmlnode_set_attrib(node, "value", buf); } else if (pref->type == PURPLE_PREF_STRING) { @@ -161,7 +161,7 @@ } else if (pref->type == PURPLE_PREF_BOOLEAN) { xmlnode_set_attrib(node, "type", "bool"); - snprintf(buf, sizeof(buf), "%d", pref->value.boolean); + g_snprintf(buf, sizeof(buf), "%d", pref->value.boolean); xmlnode_set_attrib(node, "value", buf); }
--- a/libpurple/savedstatuses.c Sat May 16 19:06:53 2009 +0000 +++ b/libpurple/savedstatuses.c Sat May 16 19:58:40 2009 +0000 @@ -285,13 +285,13 @@ xmlnode_set_attrib(node, "transient", "true"); } - snprintf(buf, sizeof(buf), "%lu", status->creation_time); + g_snprintf(buf, sizeof(buf), "%lu", status->creation_time); xmlnode_set_attrib(node, "created", buf); - snprintf(buf, sizeof(buf), "%lu", status->lastused); + g_snprintf(buf, sizeof(buf), "%lu", status->lastused); xmlnode_set_attrib(node, "lastused", buf); - snprintf(buf, sizeof(buf), "%u", status->usage_count); + g_snprintf(buf, sizeof(buf), "%u", status->usage_count); xmlnode_set_attrib(node, "usage_count", buf); child = xmlnode_new_child(node, "state");
--- a/libpurple/util.c Sat May 16 19:06:53 2009 +0000 +++ b/libpurple/util.c Sat May 16 19:58:40 2009 +0000 @@ -129,7 +129,7 @@ ascii = g_malloc(len * 2 + 1); for (i = 0; i < len; i++) - snprintf(&ascii[i * 2], 3, "%02hhx", data[i]); + g_snprintf(&ascii[i * 2], 3, "%02hhx", data[i]); return ascii; }