pidgin: d82a7ce2: Add support for file context v0, which i...
qulogic at pidgin.im
qulogic at pidgin.im
Sat Oct 15 20:20:57 EDT 2011
----------------------------------------------------------------------
Revision: d82a7ce28750bfd9aecfe8c81daccdc0172e8cb3
Parent: b82934a3e05d859d76f0a5688f1d2e0e2872ac59
Author: qulogic at pidgin.im
Date: 10/15/11 20:15:40
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/d82a7ce28750bfd9aecfe8c81daccdc0172e8cb3
Changelog:
Add support for file context v0, which is used by older official MSN
clients on Macs.
Changes against parent b82934a3e05d859d76f0a5688f1d2e0e2872ac59
patched ChangeLog
patched libpurple/protocols/msn/slp.c
patched libpurple/protocols/msn/xfer.c
patched libpurple/protocols/msn/xfer.h
-------------- next part --------------
============================================================
--- ChangeLog 7470178554639ee1f5466791690ade246dab3cd4
+++ ChangeLog 65602c35204dcebecd4f1883524777a2aed56bbc
@@ -16,6 +16,9 @@ version 3.0.0 (??/??/????):
* Better handling of "invisible" and "chatty" statuses. (Tomasz
Wasilczyk) (#13836)
+ MSN:
+ * Fix file transfer with older Mac MSN clients.
+
MXit:
* Remove all reference to Hidden Number.
* Fix decoding of font-size changes in the markup of received messages.
============================================================
--- libpurple/protocols/msn/slp.c bc016f95d82aa1a8efcf91c63aa8b91fed970a5a
+++ libpurple/protocols/msn/slp.c 1294fbf257e089b8308a8e165405fb0b98f04f1c
@@ -322,7 +322,7 @@ gen_context(PurpleXfer *xfer, const char
preview = purple_xfer_get_thumbnail(xfer, &preview_len);
- context.length = MSN_FILE_CONTEXT_SIZE;
+ context.length = MSN_FILE_CONTEXT_SIZE_V2;
context.version = 2; /* V.3 contains additional unnecessary data */
context.file_size = size;
if (preview)
@@ -346,7 +346,7 @@ gen_context(PurpleXfer *xfer, const char
context.preview_len = preview_len;
u8 = msn_file_context_to_wire(&context);
- ret = purple_base64_encode((const guchar *)u8, MSN_FILE_CONTEXT_SIZE + preview_len);
+ ret = purple_base64_encode((const guchar *)u8, MSN_FILE_CONTEXT_SIZE_V2 + preview_len);
g_free(uni);
g_free(u8);
============================================================
--- libpurple/protocols/msn/xfer.c 4ae54bb0533ae49d3ed9669a68c502178b029e30
+++ libpurple/protocols/msn/xfer.c cfb12b08cc0e6feeac2fb4144c730269a6de76c7
@@ -166,7 +166,7 @@ msn_file_context_to_wire(MsnFileContext
{
gchar *ret, *tmp;
- tmp = ret = g_new(gchar, MSN_FILE_CONTEXT_SIZE + context->preview_len + 1);
+ tmp = ret = g_new(gchar, MSN_FILE_CONTEXT_SIZE_V2 + context->preview_len + 1);
msn_push32le(tmp, context->length);
msn_push32le(tmp, context->version);
@@ -196,21 +196,30 @@ msn_file_context_from_wire(const char *b
{
MsnFileContext *context;
- if (!buf || len < MSN_FILE_CONTEXT_SIZE)
+ if (!buf || len < MSN_FILE_CONTEXT_SIZE_V0)
return NULL;
context = g_new(MsnFileContext, 1);
context->length = msn_pop32le(buf);
context->version = msn_pop32le(buf);
- if (context->version == 2) {
+ if (context->version == 0) {
+ if (context->length != MSN_FILE_CONTEXT_SIZE_V0) {
+ g_free(context);
+ return NULL;
+ }
+ } else if (context->version == 2) {
/* The length field is broken for this version. No check. */
- context->length = MSN_FILE_CONTEXT_SIZE;
+ context->length = MSN_FILE_CONTEXT_SIZE_V2;
+ if (len < MSN_FILE_CONTEXT_SIZE_V2) {
+ g_free(context);
+ return NULL;
+ }
} else if (context->version == 3) {
- if (context->length != MSN_FILE_CONTEXT_SIZE + 63) {
+ if (context->length != MSN_FILE_CONTEXT_SIZE_V3) {
g_free(context);
return NULL;
- } else if (len < MSN_FILE_CONTEXT_SIZE + 63) {
+ } else if (len < MSN_FILE_CONTEXT_SIZE_V3) {
g_free(context);
return NULL;
}
@@ -224,13 +233,15 @@ msn_file_context_from_wire(const char *b
context->type = msn_pop32le(buf);
memcpy(context->file_name, buf, MAX_FILE_NAME_LEN * 2);
buf += MAX_FILE_NAME_LEN * 2;
+ if (context->version > 0) {
#if 0
- memcpy(context->unknown1, buf, sizeof(context->unknown1));
- buf += sizeof(context->unknown1);
- context->unknown2 = msn_pop32le(buf);
+ memcpy(context->unknown1, buf, sizeof(context->unknown1));
+ buf += sizeof(context->unknown1);
+ context->unknown2 = msn_pop32le(buf);
#else
- buf += sizeof(gchar[30]) + sizeof(guint32);
+ buf += sizeof(gchar[30]) + sizeof(guint32);
#endif
+ }
if (context->type == 0 && len > context->length) {
context->preview_len = len - context->length;
============================================================
--- libpurple/protocols/msn/xfer.h 83dd5866b2a75890858f161033c01a696bf73e08
+++ libpurple/protocols/msn/xfer.h 4259153e0c4dcc6c1b42f2da99434d5ce260cef1
@@ -47,7 +47,9 @@ typedef struct
gsize preview_len;
} MsnFileContext;
-#define MSN_FILE_CONTEXT_SIZE (4*4 + 1*8 + 2*MAX_FILE_NAME_LEN + 30)
+#define MSN_FILE_CONTEXT_SIZE_V0 (4*3 + 1*8 + 2*MAX_FILE_NAME_LEN)
+#define MSN_FILE_CONTEXT_SIZE_V2 (MSN_FILE_CONTEXT_SIZE_V0 + 4*1 + 30)
+#define MSN_FILE_CONTEXT_SIZE_V3 (MSN_FILE_CONTEXT_SIZE_V2 + 63)
void msn_xfer_init(PurpleXfer *xfer);
void msn_xfer_cancel(PurpleXfer *xfer);
More information about the Commits
mailing list