Skip to content

Commit

Permalink
better workaround for libotr's NULL opdata bug
Browse files Browse the repository at this point in the history
  • Loading branch information
pesco committed Aug 2, 2013
1 parent 22ec21d commit fa9478e
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions otr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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'",
Expand Down

0 comments on commit fa9478e

Please sign in to comment.