diff options
| author | unknown <pesco@khjk.org> | 2013-08-02 17:30:11 +0200 | 
|---|---|---|
| committer | unknown <pesco@khjk.org> | 2013-08-02 17:30:11 +0200 | 
| commit | fa9478ea664824841c013615c0c4b324c8c78c0a (patch) | |
| tree | 23f9568911540600b71b72aa3ea9dc67d64380f0 /otr.c | |
| parent | 22ec21d76219508284af193d37cc4a2cbab65e7d (diff) | |
better workaround for libotr's NULL opdata bug
Diffstat (limited to 'otr.c')
| -rw-r--r-- | otr.c | 19 | 
1 files changed, 13 insertions, 6 deletions
@@ -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'",  | 
