Revision: 18016
http://svn.sourceforge.net/gaim/?rev=18016&view=rev
Author: boler
Date: 2006-12-17 05:07:25 -0800 (Sun, 17 Dec 2006)
Log Message:
-----------
gg: Don't crash with unexpected buddy list format. (Fixes #1609482)
Modified Paths:
--------------
trunk/libgaim/protocols/gg/buddylist.c
trunk/libgaim/protocols/gg/gg-utils.c
trunk/libgaim/protocols/gg/gg-utils.h
Modified: trunk/libgaim/protocols/gg/buddylist.c
===================================================================
--- trunk/libgaim/protocols/gg/buddylist.c 2006-12-17 12:59:04 UTC (rev 18015)
+++ trunk/libgaim/protocols/gg/buddylist.c 2006-12-17 13:07:25 UTC (rev 18016)
@@ -90,10 +90,8 @@
gchar **users_tbl;
int i;
- /*
- * XXX: Limit of entries in a buddylist that will be imported.
- */
- users_tbl = g_strsplit(buddylist, "\r\n", 200);
+ /* Don't limit a number of records in a buddylist. */
+ users_tbl = g_strsplit(buddylist, "\r\n", -1);
for (i = 0; users_tbl[i] != NULL; i++) {
gchar **data_tbl;
@@ -103,17 +101,23 @@
continue;
data_tbl = g_strsplit(users_tbl[i], ";", 8);
+ if (ggp_array_size(data_tbl) < 8) {
+ gaim_debug_warning("gg",
+ "Something is wrong on line %d of the buddylist. Skipping.\n",
+ i + 1);
+ continue;
+ }
show = charset_convert(data_tbl[3], "CP1250", "UTF-8");
name = data_tbl[6];
- if (NULL == name || '\0' == *name) {
+ if ('\0' == *name) {
gaim_debug_warning("gg",
"Something is wrong on line %d of the buddylist. Skipping.\n",
i + 1);
continue;
}
- if (NULL == show || '\0' == *show) {
+ if ('\0' == *show) {
show = g_strdup(name);
}
@@ -127,10 +131,11 @@
g = g_strdup("Gadu-Gadu");
- if (strlen(data_tbl[5])) {
+ if ('\0' != data_tbl[5]) {
+ /* XXX: Probably buddy should be added to all the groups. */
/* Hard limit to at most 50 groups */
gchar **group_tbl = g_strsplit(data_tbl[5], ",", 50);
- if (strlen(group_tbl[0]) > 0) {
+ if (ggp_array_size(group_tbl) > 0) {
g_free(g);
g = g_strdup(group_tbl[0]);
}
Modified: trunk/libgaim/protocols/gg/gg-utils.c
===================================================================
--- trunk/libgaim/protocols/gg/gg-utils.c 2006-12-17 12:59:04 UTC (rev 18015)
+++ trunk/libgaim/protocols/gg/gg-utils.c 2006-12-17 13:07:25 UTC (rev 18016)
@@ -50,6 +50,18 @@
}
/* }}} */
+/* unsigned int ggp_array_size(char **array) {{{ */
+unsigned int ggp_array_size(char **array)
+{
+ unsigned int i;
+
+ for (i = 0; array[i] != NULL && i < UINT_MAX; i++)
+ {}
+
+ return i;
+}
+/* }}} */
+
/* char *charset_convert(const gchar *locstr, const char *encsrc, const char *encdst) {{{ */
char *charset_convert(const gchar *locstr, const char *encsrc, const char *encdst)
{
Modified: trunk/libgaim/protocols/gg/gg-utils.h
===================================================================
--- trunk/libgaim/protocols/gg/gg-utils.h 2006-12-17 12:59:04 UTC (rev 18015)
+++ trunk/libgaim/protocols/gg/gg-utils.h 2006-12-17 13:07:25 UTC (rev 18016)
@@ -38,16 +38,27 @@
#include "gg.h"
-/*
+/**
* Convert a base 10 string to a UIN.
*
* @param str The string to convert
- * @return UIN or 0 if an error occurred.
+ *
+ * @return UIN or 0 if an error occurred.
*/
uin_t
ggp_str_to_uin(const char *str);
/**
+ * Calculate size of a NULL-terminated array.
+ *
+ * @param array The array.
+ *
+ * @return Size of the array.
+ */
+unsigned int
+ggp_array_size(char **array);
+
+/**
* Convert enconding of a given string.
*
* @param locstr Input string.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|