From fa9478ea664824841c013615c0c4b324c8c78c0a Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 2 Aug 2013 17:30:11 +0200 Subject: better workaround for libotr's NULL opdata bug --- otr.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'otr.c') diff --git a/otr.c b/otr.c index 1637812a..94b2134a 100644 --- a/otr.c +++ b/otr.c @@ -664,12 +664,6 @@ void op_still_secure(void *opdata, ConnContext *context, int is_reply) int op_max_message_size(void *opdata, ConnContext *context) { - /* libotr 4.0.0 has a bug where it doesn't set opdata */ - if(!opdata) { - /* crude fallback */ - return 800; - } - struct im_connection *ic = check_imc(opdata, context->accountname, context->protocol); @@ -1369,6 +1363,19 @@ struct im_connection *check_imc(void *opdata, const char *accountname, { struct im_connection *ic = (struct im_connection *)opdata; + /* libotr 4.0.0 has a bug where it doesn't set opdata, so we catch + * that and try to find the desired connection in the global list. */ + if(!ic) { + GSList *l; + for(l=get_connections(); l; l=l->next) { + ic = l->data; + if(strcmp(accountname, ic->acc->user) == 0 && + strcmp(protocol, ic->acc->prpl->name) == 0) + break; + } + assert(l != NULL); /* a match should always be found */ + } + if (strcmp(accountname, ic->acc->user) != 0) { log_message(LOGLVL_WARNING, "otr: internal account name mismatch: '%s' vs '%s'", -- cgit v1.2.3