diff options
author | Sven Moritz Hallberg <pesco@khjk.org> | 2010-09-19 21:12:49 +0200 |
---|---|---|
committer | Sven Moritz Hallberg <pesco@khjk.org> | 2010-09-19 21:12:49 +0200 |
commit | 9cc653c46593ba801e346ef3e3b20e925bc0541b (patch) | |
tree | 7a13c33bff01e232ba0e9393ccd28fe785aac1d1 /otr.c | |
parent | 21710443be24b793dd14dc22ba6899ac25af3eca (diff) |
let 'otr smpq' only work for smp init, not reply
Diffstat (limited to 'otr.c')
-rw-r--r-- | otr.c | 35 |
1 files changed, 19 insertions, 16 deletions
@@ -1187,26 +1187,29 @@ void otr_initiate_smp(irc_t *irc, const char *nick, const char *question, otrl_sm_state_free(ctx->smstate); } - /* warning: the following assumes that smstates are cleared whenever an SMP - is completed or aborted! */ - if(ctx->smstate->secret == NULL) { + if(question) { + /* this was 'otr smpq', just initiate */ irc_usermsg(irc, "smp: initiating with %s...", u->nick); - if(question) { - otrl_message_initiate_smp_q(irc->otr->us, &otr_ops, - u->bu->ic, ctx, question, - (unsigned char *)secret, strlen(secret)); - } else { + otrl_message_initiate_smp_q(irc->otr->us, &otr_ops, u->bu->ic, ctx, + question, (unsigned char *)secret, strlen(secret)); + /* smp is now in EXPECT2 */ + } else { + /* this was 'otr smp', initiate or reply */ + /* warning: the following assumes that smstates are cleared whenever an SMP + is completed or aborted! */ + if(ctx->smstate->secret == NULL) { + irc_usermsg(irc, "smp: initiating with %s...", u->nick); otrl_message_initiate_smp(irc->otr->us, &otr_ops, u->bu->ic, ctx, (unsigned char *)secret, strlen(secret)); + /* smp is now in EXPECT2 */ + } else { + /* if we're still in EXPECT1 but smstate is initialized, we must have + received the SMP1, so let's issue a response */ + irc_usermsg(irc, "smp: responding to %s...", u->nick); + otrl_message_respond_smp(irc->otr->us, &otr_ops, + u->bu->ic, ctx, (unsigned char *)secret, strlen(secret)); + /* smp is now in EXPECT3 */ } - /* smp is now in EXPECT2 */ - } else { - /* if we're still in EXPECT1 but smstate is initialized, we must have - received the SMP1, so let's issue a response */ - irc_usermsg(irc, "smp: responding to %s...", u->nick); - otrl_message_respond_smp(irc->otr->us, &otr_ops, - u->bu->ic, ctx, (unsigned char *)secret, strlen(secret)); - /* smp is now in EXPECT3 */ } } |