Changeset a0c6fc5


Ignore:
Timestamp:
2011-06-25T22:28:26Z (8 years ago)
Author:
Sven Moritz Hallberg <pesco@…>
Branches:
master
Children:
1dc00fe
Parents:
9e7a566
Message:

fix possible segfault(s) when changing otr status

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • Makefile

    r9e7a566 ra0c6fc5  
    164164
    165165-include .depend/*.d
     166# DO NOT DELETE
  • otr.c

    r9e7a566 ra0c6fc5  
    162162void otr_smp_or_smpq(irc_t *irc, const char *nick, const char *question,
    163163                const char *secret);
     164
     165/* update flags within the irc_user structure to reflect OTR status of context */
     166void otr_update_uflags(ConnContext *context, irc_user_t *u);
    164167
    165168/* update op/voice flag of given user according to encryption state and settings
     
    608611        irc_user_t *u;
    609612        irc_t *irc = ic->bee->ui_data;
    610         const char *trust;
    611613
    612614        u = peeruser(irc, context->username, context->protocol);
     
    618620        }
    619621       
    620         trust = context->active_fingerprint->trust;
    621         if(trust && trust[0])
    622                 u->flags |= IRC_USER_OTR_ENCRYPTED | IRC_USER_OTR_TRUSTED;
    623         else
    624                 u->flags = ( u->flags & ~IRC_USER_OTR_TRUSTED ) | IRC_USER_OTR_ENCRYPTED;
     622        otr_update_uflags(context, u);
    625623        if(!otr_update_modeflags(irc, u))
    626624                irc_usermsg(irc, "conversation with %s is now off the record", u->nick);
     
    641639                return;
    642640        }
    643         u->flags &= ~( IRC_USER_OTR_ENCRYPTED | IRC_USER_OTR_TRUSTED );
     641        otr_update_uflags(context, u);
    644642        if(!otr_update_modeflags(irc, u))
    645643                irc_usermsg(irc, "conversation with %s is now in the clear", u->nick);
     
    660658                return;
    661659        }
    662         if(context->active_fingerprint->trust[0])
    663                 u->flags |= IRC_USER_OTR_ENCRYPTED | IRC_USER_OTR_TRUSTED;
    664         else
    665                 u->flags = ( u->flags & ~IRC_USER_OTR_TRUSTED ) | IRC_USER_OTR_ENCRYPTED;
     660
     661        otr_update_uflags(context, u);
    666662        if(!otr_update_modeflags(irc, u))
    667663                irc_usermsg(irc, "otr connection with %s has been refreshed", u->nick);
     
    13121308}
    13131309
     1310void otr_update_uflags(ConnContext *context, irc_user_t *u)
     1311{
     1312        const char *trust;
     1313
     1314        if(context->active_fingerprint) {
     1315                u->flags |= IRC_USER_OTR_ENCRYPTED;
     1316
     1317                trust = context->active_fingerprint->trust;
     1318                if(trust && trust[0])
     1319                        u->flags |= IRC_USER_OTR_TRUSTED;
     1320                else
     1321                        u->flags &= ~IRC_USER_OTR_TRUSTED;
     1322        } else {
     1323                u->flags &= ~IRC_USER_OTR_ENCRYPTED;
     1324        }
     1325}
     1326
    13141327int otr_update_modeflags(irc_t *irc, irc_user_t *u)
    13151328{
Note: See TracChangeset for help on using the changeset viewer.