Changeset 88de0c9


Ignore:
Timestamp:
2010-10-02T05:28:43Z (9 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
3ad8036, 8e9e2b7
Parents:
560129a (diff), faa75c0e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merging some more fixes (dealing with incoming smpq stuff).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • otr.c

    r560129a r88de0c9  
    88  OTR support (cf. http://www.cypherpunks.ca/otr/)
    99 
    10   2008, Sven Moritz Hallberg <pesco@khjk.org>
    11   (c) and funded by stonedcoder.org
     10  (c) 2008-2010 Sven Moritz Hallberg <pesco@khjk.org>
     11  (c) 2008 funded by stonedcoder.org
    1212   
    1313  files used to store OTR data:
     
    158158
    159159/* combined handler for the 'otr smp' and 'otr smpq' commands */
    160 void otr_initiate_smp(irc_t *irc, const char *nick, const char *question,
     160void otr_smp_or_smpq(irc_t *irc, const char *nick, const char *question,
    161161                const char *secret);
    162162
     
    738738void cmd_otr_smp(irc_t *irc, char **args)
    739739{
    740         otr_initiate_smp(irc, args[1], NULL, args[2]);  /* no question */
     740        otr_smp_or_smpq(irc, args[1], NULL, args[2]);   /* no question */
    741741}
    742742
    743743void cmd_otr_smpq(irc_t *irc, char **args)
    744744{
    745         otr_initiate_smp(irc, args[1], args[2], args[3]);
     745        otr_smp_or_smpq(irc, args[1], args[2], args[3]);
    746746}
    747747
     
    10741074        nextMsg = context->smstate->nextExpected;
    10751075
     1076        if (context->smstate->sm_prog_state == OTRL_SMP_PROG_CHEATED) {
     1077                irc_usermsg(irc, "smp %s: opponent violated protocol, aborting",
     1078                        u->nick);
     1079                otrl_message_abort_smp(us, ops, u->bu->ic, context);
     1080                otrl_sm_state_free(context->smstate);
     1081                return;
     1082        }
     1083
    10761084        tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP1Q);
    10771085        if (tlv) {
     
    10821090                } else {
    10831091                        char *question = g_strndup((char *)tlv->data, tlv->len);
    1084                         irc_usermsg(irc, "smp: initiated by %s with question: \"%s\"", u->nick,
     1092                        irc_usermsg(irc, "smp: initiated by %s with question: \x02\"%s\"\x02", u->nick,
    10851093                                question);
    10861094                        irc_usermsg(irc, "smp: respond with \x02otr smp %s <answer>\x02",
     
    11221130                } else {
    11231131                        /* SMP3 received, otrl_message_receiving will have sent SMP4 and set fp trust */
    1124                         const char *trust = context->active_fingerprint->trust;
    1125                         if(!trust || trust[0]=='\0') {
    1126                                 irc_usermsg(irc, "smp %s: secrets did not match, fingerprint not trusted",
     1132                        /* as noted above, fp trust SHOULD have been set by libotr.
     1133                         * however at least version 3.2.0 seems to forget it when
     1134                         * responding to an smp session that was initiated with SMP1Q
     1135                         * (question and answer); other cases appear to work fine.
     1136                         * as a workaround, we explicitly set it below.
     1137                         */
     1138                        if(context->smstate->sm_prog_state == OTRL_SMP_PROG_SUCCEEDED) {
     1139                                otrl_context_set_trust(context->active_fingerprint, "smp");
     1140                                irc_usermsg(irc, "smp %s: secrets proved equal, fingerprint trusted",
    11271141                                        u->nick);
    11281142                        } else {
    1129                                 irc_usermsg(irc, "smp %s: secrets proved equal, fingerprint trusted",
     1143                                otrl_context_set_trust(context->active_fingerprint, "");
     1144                                irc_usermsg(irc, "smp %s: secrets did not match, fingerprint not trusted",
    11301145                                        u->nick);
    11311146                        }
     
    11421157                } else {
    11431158                        /* SMP4 received, otrl_message_receiving will have set fp trust */
    1144                         const char *trust = context->active_fingerprint->trust;
    1145                         if(!trust || trust[0]=='\0') {
    1146                                 irc_usermsg(irc, "smp %s: secrets did not match, fingerprint not trusted",
     1159                        if(context->smstate->sm_prog_state == OTRL_SMP_PROG_SUCCEEDED) {
     1160                                irc_usermsg(irc, "smp %s: secrets proved equal, fingerprint trusted",
    11471161                                        u->nick);
    11481162                        } else {
    1149                                 irc_usermsg(irc, "smp %s: secrets proved equal, fingerprint trusted",
     1163                                irc_usermsg(irc, "smp %s: secrets did not match, fingerprint not trusted",
    11501164                                        u->nick);
    11511165                        }
     
    11631177
    11641178/* combined handler for the 'otr smp' and 'otr smpq' commands */
    1165 void otr_initiate_smp(irc_t *irc, const char *nick, const char *question,
     1179void otr_smp_or_smpq(irc_t *irc, const char *nick, const char *question,
    11661180                const char *secret)
    11671181{
     
    11941208                otrl_sm_state_free(ctx->smstate);
    11951209        }
    1196        
     1210
    11971211        if(question) {
    11981212                /* this was 'otr smpq', just initiate */
Note: See TracChangeset for help on using the changeset viewer.