On Wed, Aug 14, 2013 at 04:21:16PM +0200, Stefan Sperling wrote:
> On Wed, Aug 14, 2013 at 09:49:18AM -0400, Jiri B wrote:
> > On Wed, Aug 14, 2013 at 03:06:32PM +0200, Stefan Sperling wrote:
> > > Should we hold back this update until bitlbee and mcabber provide
> > > patches for OTR-4? Or leave them broken until then? Or should I
> > > add a new libotr4 port instead that conflicts with otr3?
> > 
> > Please do not break bitlbee-otr, I use it everyday and I depend
> > ot it.
> > 
> > Thanks.
> > 
> > jirib
> 
> Please try this as well, then.

Found a possible crash bug in my otr.c patch.
Try this one instead, please.

Index: Makefile
===================================================================
RCS file: /cvs/ports/net/bitlbee/Makefile,v
retrieving revision 1.51
diff -u -p -r1.51 Makefile
--- Makefile    27 Apr 2013 15:44:21 -0000      1.51
+++ Makefile    14 Aug 2013 14:17:55 -0000
@@ -4,7 +4,7 @@ COMMENT=                IRC proxy to connect to AIM, I
 
 DISTNAME=              bitlbee-3.2
 CATEGORIES=            net
-REVISION=              1
+REVISION=              2
 
 HOMEPAGE=              http://bitlbee.org/
 
Index: patches/patch-otr_c
===================================================================
RCS file: patches/patch-otr_c
diff -N patches/patch-otr_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-otr_c 14 Aug 2013 14:26:12 -0000
@@ -0,0 +1,226 @@
+$OpenBSD$
+support for libotr-4.0
+--- otr.c.orig Wed Aug 14 14:46:03 2013
++++ otr.c      Wed Aug 14 16:25:36 2013
+@@ -73,12 +73,12 @@ void op_gone_insecure(void *opdata, ConnContext *conte
+ 
+ void op_still_secure(void *opdata, ConnContext *context, int is_reply);
+ 
+-void op_log_message(void *opdata, const char *message);
+-
+ int op_max_message_size(void *opdata, ConnContext *context);
+ 
+ const char *op_account_name(void *opdata, const char *account, const char 
*protocol);
+ 
++void op_handle_msg_event(void *opdata, OtrlMessageEvent msg_event,
++    ConnContext *context, const char *message, gcry_error_t err);
+ 
+ /** otr sub-command handlers: **/
+ 
+@@ -207,20 +207,26 @@ void init_plugin(void)
+       otr_ops.create_privkey = &op_create_privkey;
+       otr_ops.is_logged_in = &op_is_logged_in;
+       otr_ops.inject_message = &op_inject_message;
+-      otr_ops.notify = NULL;
+-      otr_ops.display_otr_message = &op_display_otr_message;
+       otr_ops.update_context_list = NULL;
+-      otr_ops.protocol_name = NULL;
+-      otr_ops.protocol_name_free = NULL;
+       otr_ops.new_fingerprint = &op_new_fingerprint;
+       otr_ops.write_fingerprints = &op_write_fingerprints;
+       otr_ops.gone_secure = &op_gone_secure;
+       otr_ops.gone_insecure = &op_gone_insecure;
+       otr_ops.still_secure = &op_still_secure;
+-      otr_ops.log_message = &op_log_message;
+       otr_ops.max_message_size = &op_max_message_size;
+       otr_ops.account_name = &op_account_name;
+       otr_ops.account_name_free = NULL;
++      otr_ops.received_symkey = NULL;
++      otr_ops.otr_error_message = NULL;
++      otr_ops.otr_error_message_free = NULL;
++      otr_ops.resent_msg_prefix = NULL;
++      otr_ops.resent_msg_prefix_free = NULL;
++      otr_ops.handle_smp_event = NULL;
++      otr_ops.handle_msg_event = &op_handle_msg_event;
++      otr_ops.create_instag = NULL;
++      otr_ops.convert_msg = NULL;
++      otr_ops.convert_free = NULL;
++      otr_ops.timer_control = NULL;
+       
+       root_command_add( "otr", 1, cmd_otr, 0 );
+       register_irc_plugin( &otr_plugin );
+@@ -385,7 +391,7 @@ char *otr_filter_msg_in(irc_user_t *iu, char *msg, int
+       
+       ignore_msg = otrl_message_receiving(irc->otr->us, &otr_ops, ic,
+               ic->acc->user, ic->acc->prpl->name, iu->bu->handle, msg, 
&newmsg,
+-              &tlvs, NULL, NULL);
++              &tlvs, NULL, NULL, NULL);
+ 
+       otr_handle_smp(ic, iu->bu->handle, tlvs);
+       
+@@ -398,7 +404,8 @@ char *otr_filter_msg_in(irc_user_t *iu, char *msg, int
+       } else {
+               /* OTR has processed this message */
+               ConnContext *context = otrl_context_find(irc->otr->us, 
iu->bu->handle,
+-                      ic->acc->user, ic->acc->prpl->name, 0, NULL, NULL, 
NULL);
++                      ic->acc->user, ic->acc->prpl->name, OTRL_INSTAG_BEST, 
0, NULL,
++                      NULL, NULL);
+ 
+               /* we're done with the original msg, which will be 
caller-freed. */
+               /* NB: must not change the newmsg pointer, since we free it. */
+@@ -466,7 +473,7 @@ char *otr_filter_msg_out(irc_user_t *iu, char *msg, in
+ 
+       ctx = otrl_context_find(irc->otr->us,
+                       iu->bu->handle, ic->acc->user, ic->acc->prpl->name,
+-                      1, NULL, NULL, NULL);
++                      OTRL_INSTAG_BEST, 1, NULL, NULL, NULL);
+ 
+       /* HTML encoding */
+       /* consider OTR plaintext to be HTML if otr_does_html is set */
+@@ -478,28 +485,15 @@ char *otr_filter_msg_out(irc_user_t *iu, char *msg, in
+       
+       st = otrl_message_sending(irc->otr->us, &otr_ops, ic,
+               ic->acc->user, ic->acc->prpl->name, iu->bu->handle,
+-              emsg, NULL, &otrmsg, NULL, NULL);
++              OTRL_INSTAG_BEST, emsg, NULL, &otrmsg,
++              OTRL_FRAGMENT_SEND_ALL, NULL, NULL, NULL);
+       if(emsg != msg) {
+               g_free(emsg);   /* we're done with this one */
+       }
+       if(st) {
+-              return NULL;
+-      }
+-
+-      if(otrmsg) {
+-              if(!ctx) {
+-                      otrl_message_free(otrmsg);
+-                      return NULL;
+-              }
+-              st = otrl_message_fragment_and_send(&otr_ops, ic, ctx,
+-                      otrmsg, OTRL_FRAGMENT_SEND_ALL, NULL);
+-              otrl_message_free(otrmsg);
+-      } else {
+-              /* note: otrl_message_sending handles policy, so that if 
REQUIRE_ENCRYPTION is set,
+-                 this case does not occur */
+               return msg;
+       }
+-      
++
+       /* TODO: Error reporting should be done here now (if st!=0), probably. 
*/
+       
+       return NULL;
+@@ -639,6 +633,15 @@ int op_display_otr_message(void *opdata, const char *a
+       return 0;
+ }
+ 
++void
++op_handle_msg_event(void *opdata, OtrlMessageEvent msg_event,
++    ConnContext *context, const char *message, gcry_error_t err)
++{
++      if (message)
++              op_display_otr_message(opdata, context->accountname, 
context->protocol,
++                      context->username, message);
++}
++
+ void op_new_fingerprint(void *opdata, OtrlUserState us,
+       const char *accountname, const char *protocol,
+       const char *username, unsigned char fingerprint[20])
+@@ -729,15 +732,6 @@ void op_still_secure(void *opdata, ConnContext *contex
+       }
+ }
+ 
+-void op_log_message(void *opdata, const char *message)
+-{
+-      char *msg = g_strdup(message);
+-      
+-      strip_html(msg);
+-      log_message(LOGLVL_INFO, "otr: %s", msg);
+-      g_free(msg);
+-}
+-
+ int op_max_message_size(void *opdata, ConnContext *context)
+ {
+       struct im_connection *ic =
+@@ -774,13 +768,14 @@ void cmd_otr_disconnect(irc_t *irc, char **args)
+       }
+       
+       otrl_message_disconnect(irc->otr->us, &otr_ops,
+-              u->bu->ic, u->bu->ic->acc->user, u->bu->ic->acc->prpl->name, 
u->bu->handle);
++              u->bu->ic, u->bu->ic->acc->user, u->bu->ic->acc->prpl->name, 
u->bu->handle,
++              OTRL_INSTAG_BEST);
+       
+       /* for some reason, libotr (3.1.0) doesn't do this itself: */
+       if(u->flags & IRC_USER_OTR_ENCRYPTED) {
+               ConnContext *ctx;
+               ctx = otrl_context_find(irc->otr->us, u->bu->handle, 
u->bu->ic->acc->user,
+-                      u->bu->ic->acc->prpl->name, 0, NULL, NULL, NULL);
++                      u->bu->ic->acc->prpl->name, OTRL_INSTAG_BEST, 0, NULL, 
NULL, NULL);
+               if(ctx)
+                       op_gone_insecure(u->bu->ic, ctx);
+               else /* huh? */
+@@ -830,7 +825,8 @@ void cmd_otr_trust(irc_t *irc, char **args)
+       }
+       
+       ctx = otrl_context_find(irc->otr->us, u->bu->handle,
+-              u->bu->ic->acc->user, u->bu->ic->acc->prpl->name, 0, NULL, 
NULL, NULL);
++              u->bu->ic->acc->user, u->bu->ic->acc->prpl->name, 
OTRL_INSTAG_BEST,
++              0, NULL, NULL, NULL);
+       if(!ctx) {
+               irc_rootmsg(irc, "%s: no otr context with user", args[1]);
+               return;
+@@ -894,7 +890,8 @@ void cmd_otr_info(irc_t *irc, char **args)
+               if(protocol && myhandle) {
+                       *(myhandle++) = '\0';
+                       handle = arg;
+-                      ctx = otrl_context_find(irc->otr->us, handle, myhandle, 
protocol, 0, NULL, NULL, NULL);
++                      ctx = otrl_context_find(irc->otr->us, handle, myhandle,
++                        protocol, OTRL_INSTAG_BEST, 0, NULL, NULL, NULL);
+                       if(!ctx) {
+                               irc_rootmsg(irc, "no such context");
+                               g_free(arg);
+@@ -908,7 +905,7 @@ void cmd_otr_info(irc_t *irc, char **args)
+                               return;
+                       }
+                       ctx = otrl_context_find(irc->otr->us, u->bu->handle, 
u->bu->ic->acc->user,
+-                              u->bu->ic->acc->prpl->name, 0, NULL, NULL, 
NULL);
++                              u->bu->ic->acc->prpl->name, OTRL_INSTAG_BEST, 
0, NULL, NULL, NULL);
+                       if(!ctx) {
+                               irc_rootmsg(irc, "no otr context with %s", 
args[1]);
+                               g_free(arg);
+@@ -1027,7 +1024,7 @@ void cmd_otr_forget(irc_t *irc, char **args)
+               }
+               
+               ctx = otrl_context_find(irc->otr->us, u->bu->handle, 
u->bu->ic->acc->user,
+-                      u->bu->ic->acc->prpl->name, 0, NULL, NULL, NULL);
++                      u->bu->ic->acc->prpl->name, OTRL_INSTAG_BEST, 0, NULL, 
NULL, NULL);
+               if(!ctx) {
+                       irc_rootmsg(irc, "no otr context with %s", args[2]);
+                       return;
+@@ -1070,7 +1067,7 @@ void cmd_otr_forget(irc_t *irc, char **args)
+               }
+               
+               ctx = otrl_context_find(irc->otr->us, u->bu->handle, 
u->bu->ic->acc->user,
+-                      u->bu->ic->acc->prpl->name, 0, NULL, NULL, NULL);
++                      u->bu->ic->acc->prpl->name, OTRL_INSTAG_BEST, 0, NULL, 
NULL, NULL);
+               if(!ctx) {
+                       irc_rootmsg(irc, "no otr context with %s", args[2]);
+                       return;
+@@ -1133,7 +1130,7 @@ void otr_handle_smp(struct im_connection *ic, const ch
+       bu = bee_user_by_handle(ic->bee, ic, handle);
+       if(!bu || !(u = bu->ui_data)) return;
+       context = otrl_context_find(us, handle,
+-              ic->acc->user, ic->acc->prpl->name, 1, NULL, NULL, NULL);
++              ic->acc->user, ic->acc->prpl->name, OTRL_INSTAG_BEST, 1, NULL, 
NULL, NULL);
+       if(!context) {
+               /* huh? out of memory or what? */
+               irc_rootmsg(irc, "smp: failed to get otr context for %s", 
u->nick);
+@@ -1265,7 +1262,8 @@ void otr_smp_or_smpq(irc_t *irc, const char *nick, con
+       }
+       
+       ctx = otrl_context_find(irc->otr->us, u->bu->handle,
+-              u->bu->ic->acc->user, u->bu->ic->acc->prpl->name, 0, NULL, 
NULL, NULL);
++              u->bu->ic->acc->user, u->bu->ic->acc->prpl->name, 
OTRL_INSTAG_BEST,
++                0, NULL, NULL, NULL);
+       if(!ctx || ctx->msgstate != OTRL_MSGSTATE_ENCRYPTED) {
+               irc_rootmsg(irc, "smp: otr inactive with %s, try \x02otr 
connect"
+                               " %s\x02", nick, nick);

Reply via email to