# HG changeset patch # User Mark Doliner # Date 1191111610 0 # Node ID 217d520f7edb0ee03e9fd0494be1130fff21b322 # Parent 803f0ee0c2312643a3094f3e8426633f43c08bc4 Close the direct IM session if someone tries to send us a file over 50MB. Fixes #3336. diff -r 803f0ee0c231 -r 217d520f7edb libpurple/protocols/oscar/odc.c --- a/libpurple/protocols/oscar/odc.c Sat Sep 29 20:49:34 2007 +0000 +++ b/libpurple/protocols/oscar/odc.c Sun Sep 30 00:20:10 2007 +0000 @@ -27,6 +27,8 @@ #include "imgstore.h" #include "util.h" +#define DIRECTIM_MAX_FILESIZE 52428800 + /** * Free any ODC related data and print a message to the conversation * window based on conn->disconnect_reason. @@ -587,6 +589,27 @@ if (frame->payload.len > 0) { + if (frame->payload.len > DIRECTIM_MAX_FILESIZE) + { + gchar *tmp, *size1, *size2; + PurpleAccount *account; + PurpleConversation *conv; + + size1 = purple_str_size_to_units(frame->payload.len); + size2 = purple_str_size_to_units(DIRECTIM_MAX_FILESIZE); + tmp = g_strdup_printf(_("%s tried to send you a %s file, but we only allow files up to %s over Direct IM. Try using file transfer instead.\n"), conn->sn, size1, size2); + g_free(size1); + g_free(size2); + + account = purple_connection_get_account(conn->od->gc); + conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, conn->sn); + purple_conversation_write(conv, NULL, tmp, PURPLE_MESSAGE_SYSTEM, time(NULL)); + g_free(tmp); + + peer_connection_destroy(conn, OSCAR_DISCONNECT_LOCAL_CLOSED, NULL); + return; + } + /* We have payload data! Switch to the ODC watcher to read it. */ frame->payload.data = g_new(guint8, frame->payload.len); frame->payload.offset = 0;