Changeset 71004a3


Ignore:
Timestamp:
2014-02-06T22:51:19Z (10 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
c239fff
Parents:
cc17b76 (diff), 329f9fe (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 OTR fixes from pesco.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • otr.c

    rcc17b76 r71004a3  
    441441        int st;
    442442        char *otrmsg = NULL;
    443         char *emsg = msg;           /* the message as we hand it to libotr */
    444443        ConnContext *ctx = NULL;
    445444        irc_t *irc = iu->irc;
    446445        struct im_connection *ic = iu->bu->ic;
    447         otrl_instag_t instag = OTRL_INSTAG_RECENT; // XXX?
     446        otrl_instag_t instag = OTRL_INSTAG_BEST; // XXX?
     447        /* NB: in libotr 4.0.0 OTRL_INSTAG_RECENT will cause a null-pointer deref
     448         * in otrl_message_sending with newly-added OTR contexts.
     449         */
    448450
    449451        /* don't do OTR on certain (not classic IM) protocols, e.g. twitter */
     
    454456        st = otrl_message_sending(irc->otr->us, &otr_ops, ic,
    455457                ic->acc->user, ic->acc->prpl->name, iu->bu->handle, instag,
    456                 emsg, NULL, &otrmsg, OTRL_FRAGMENT_SEND_SKIP, &ctx, NULL, NULL);
    457         /* in libotr 4.0.0 with OTRL_FRAGMENT_SEND_ALL, otrmsg must be passed
    458          * but the value it gets carries no meaning. it can be set even though
    459          * the message has been injected.
    460          * With OTRL_FRAGMENT_SEND_SKIP, libotr doesn't handle the sending, it's
    461          * up to us.
    462          */
    463 
    464         if(emsg != msg) {
    465                 g_free(emsg);   /* we're done with this one */
    466                 emsg = NULL;
    467         }
     458                msg, NULL, &otrmsg, OTRL_FRAGMENT_SEND_ALL_BUT_LAST, &ctx, NULL, NULL);
     459
     460        if(otrmsg && otrmsg != msg) {
     461                /* libotr wants us to replace our message */
     462                /* NB: caller will free old msg */
     463                msg = g_strdup(otrmsg);
     464                otrl_message_free(otrmsg);
     465        }
     466       
    468467        if(st) {
    469                 irc_rootmsg(irc, "Error encrypting text for OTR: %d", st);
    470         }
    471        
    472         if (otrmsg != NULL) {
    473                 return otrmsg;
    474         }
    475         return emsg;
     468                irc_usernotice(iu, "otr: error handling outgoing message: %d", st);
     469                msg = NULL;     /* do not send plaintext! */
     470        }
     471
     472        return msg;
    476473}
    477474
     
    13511348        irc_user_t *u;
    13521349        ConnContext *ctx;
    1353         otrl_instag_t instag = OTRL_INSTAG_RECENT;  // XXX
     1350        otrl_instag_t instag = OTRL_INSTAG_BEST;  // XXX
    13541351
    13551352        u = irc_user_by_name(irc, nick);
Note: See TracChangeset for help on using the changeset viewer.