[gaim-migrate @ 18015]

Sun, 17 Dec 2006 12:59:04 +0000

author
Bartosz Oler <bartosz@pidgin.im>
date
Sun, 17 Dec 2006 12:59:04 +0000
changeset 15287
be6664498b13
parent 15286
ecc4149f47fb
child 15288
ee9ffc3db216

[gaim-migrate @ 18015]
gg: Don't send messages exceeding GG_MSG_MAXSIZE. (Fixes #1614894)

libgaim/protocols/gg/gg.c file | annotate | diff | comparison | revisions
--- a/libgaim/protocols/gg/gg.c	Sun Dec 17 08:06:48 2006 +0000
+++ b/libgaim/protocols/gg/gg.c	Sun Dec 17 12:59:04 2006 +0000
@@ -1761,24 +1761,31 @@
 {
 	GGPInfo *info = gc->proto_data;
 	char *tmp, *plain;
+	int ret = 0;
 
-	if (strlen(msg) == 0)
-		return 1;
+	if (strlen(msg) == 0) {
+		return 0;
+	}
+
+	gaim_debug_info("gg", "ggp_send_im: msg = %s\n", msg);
+	plain = gaim_unescape_html(msg);
+	tmp = charset_convert(plain, "UTF-8", "CP1250");
 
-	plain = gaim_unescape_html(msg);
-	gaim_debug_info("gg", "ggp_send_im: msg = %s\n", msg);
-	tmp = charset_convert(plain, "UTF-8", "CP1250");
+	if (NULL == tmp || strlen(tmp) == 0) {
+		ret = 0;
+	} else if (strlen(tmp) > GG_MSG_MAXSIZE) {
+		ret = -E2BIG;
+	} else if (gg_send_message(info->session, GG_CLASS_CHAT,
+				ggp_str_to_uin(who), (unsigned char *)tmp) < 0) {
+		ret = -1;
+	} else {
+		ret = 1;
+	}
+
 	g_free(plain);
-
-	if (tmp != NULL && strlen(tmp) > 0) {
-		if (gg_send_message(info->session, GG_CLASS_CHAT,
-				ggp_str_to_uin(who), (unsigned char *)tmp) < 0) {
-			return -1;
-		}
-	}
 	g_free(tmp);
 
-	return 1;
+	return ret;
 }
 /* }}} */
 

mercurial