From 9cc653c46593ba801e346ef3e3b20e925bc0541b Mon Sep 17 00:00:00 2001 From: Sven Moritz Hallberg Date: Sun, 19 Sep 2010 21:12:49 +0200 Subject: let 'otr smpq' only work for smp init, not reply --- otr.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/otr.c b/otr.c index 2baa5c12..686a947a 100644 --- a/otr.c +++ b/otr.c @@ -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 */ } } -- cgit v1.2.3