changeset 15226:9a58a9ea3995

[gaim-migrate @ 18015] gg: Don't send messages exceeding GG_MSG_MAXSIZE. (Fixes #1614894) committer: Tailor Script <tailor@pidgin.im>
author Bartoz Oler <bartosz@pidgin.im>
date Sun, 17 Dec 2006 12:59:04 +0000
parents 01fec6defb33
children 2af69418b24e
files libgaim/protocols/gg/gg.c
diffstat 1 files changed, 20 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- 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;
 }
 /* }}} */