# HG changeset patch # User Bartoz Oler # Date 1166360344 0 # Node ID 9a58a9ea399510e92ffe426c451df913bbb5663f # Parent 01fec6defb33ad3dd48a7d8b88f2891a2a9f845e [gaim-migrate @ 18015] gg: Don't send messages exceeding GG_MSG_MAXSIZE. (Fixes #1614894) committer: Tailor Script diff -r 01fec6defb33 -r 9a58a9ea3995 libgaim/protocols/gg/gg.c --- 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; } /* }}} */