diff options
| author | Sven Moritz Hallberg <pesco@khjk.org> | 2011-06-26 00:28:26 +0200 | 
|---|---|---|
| committer | Sven Moritz Hallberg <pesco@khjk.org> | 2011-06-26 00:28:26 +0200 | 
| commit | a0c6fc585aecedd236a79e3dc89e2ed67d881ad5 (patch) | |
| tree | 0475e0bd5adc22d2e5fdb333354f26e68f3b1173 /otr.c | |
| parent | 9e7a566e5c98d697636cf9e96cd38cb32d18a6d7 (diff) | |
fix possible segfault(s) when changing otr status
Diffstat (limited to 'otr.c')
| -rw-r--r-- | otr.c | 35 | 
1 files changed, 24 insertions, 11 deletions
| @@ -162,6 +162,9 @@ void otr_handle_smp(struct im_connection *ic, const char *handle, OtrlTLV *tlvs)  void otr_smp_or_smpq(irc_t *irc, const char *nick, const char *question,  		const char *secret); +/* update flags within the irc_user structure to reflect OTR status of context */ +void otr_update_uflags(ConnContext *context, irc_user_t *u); +  /* update op/voice flag of given user according to encryption state and settings     returns 0 if neither op_buddies nor voice_buddies is set to "encrypted",     i.e. msgstate should be announced seperately */ @@ -607,7 +610,6 @@ void op_gone_secure(void *opdata, ConnContext *context)  		check_imc(opdata, context->accountname, context->protocol);  	irc_user_t *u;  	irc_t *irc = ic->bee->ui_data; -	const char *trust;  	u = peeruser(irc, context->username, context->protocol);  	if(!u) { @@ -617,11 +619,7 @@ void op_gone_secure(void *opdata, ConnContext *context)  		return;  	} -	trust = context->active_fingerprint->trust; -	if(trust && trust[0]) -		u->flags |= IRC_USER_OTR_ENCRYPTED | IRC_USER_OTR_TRUSTED; -	else -		u->flags = ( u->flags & ~IRC_USER_OTR_TRUSTED ) | IRC_USER_OTR_ENCRYPTED; +	otr_update_uflags(context, u);  	if(!otr_update_modeflags(irc, u))  		irc_usermsg(irc, "conversation with %s is now off the record", u->nick);  } @@ -640,7 +638,7 @@ void op_gone_insecure(void *opdata, ConnContext *context)  			context->username, context->protocol, context->accountname);  		return;  	} -	u->flags &= ~( IRC_USER_OTR_ENCRYPTED | IRC_USER_OTR_TRUSTED ); +	otr_update_uflags(context, u);  	if(!otr_update_modeflags(irc, u))  		irc_usermsg(irc, "conversation with %s is now in the clear", u->nick);  } @@ -659,10 +657,8 @@ void op_still_secure(void *opdata, ConnContext *context, int is_reply)  			context->username, context->protocol, context->accountname);  		return;  	} -	if(context->active_fingerprint->trust[0]) -		u->flags |= IRC_USER_OTR_ENCRYPTED | IRC_USER_OTR_TRUSTED; -	else -		u->flags = ( u->flags & ~IRC_USER_OTR_TRUSTED ) | IRC_USER_OTR_ENCRYPTED; + +	otr_update_uflags(context, u);  	if(!otr_update_modeflags(irc, u))  		irc_usermsg(irc, "otr connection with %s has been refreshed", u->nick);  } @@ -1311,6 +1307,23 @@ const char *peernick(irc_t *irc, const char *handle, const char *protocol)  	}  } +void otr_update_uflags(ConnContext *context, irc_user_t *u) +{ +	const char *trust; + +	if(context->active_fingerprint) { +		u->flags |= IRC_USER_OTR_ENCRYPTED; + +		trust = context->active_fingerprint->trust; +		if(trust && trust[0]) +			u->flags |= IRC_USER_OTR_TRUSTED; +		else +			u->flags &= ~IRC_USER_OTR_TRUSTED; +	} else { +		u->flags &= ~IRC_USER_OTR_ENCRYPTED; +	} +} +  int otr_update_modeflags(irc_t *irc, irc_user_t *u)  {  	return 1; | 
