Hi otr-dev.

I was trying to figure out why bitlbee's otr plugin didn't show any
notification when the other side disconnected otr. Soon later I found
that op_gone_insecure was never called, and that there's bug #48 [1]
open for that.

Quoting from that bug:

>Is there a reason why this op is never used anywhere in the code?
>
>Sounds to me like a very important one for IM plugins to know when the session 
>is insecure. Usually, looking got the OTRL_TLV_DISCONNECTED on receive is also 
>fine to understand that the session disconnected but is there cases where we 
>might end up insecure and no TLV message is sent?

Since I don't know the reason, I decided to go ahead and write this
trivial patch, and maybe that will result in an answer to the above
question.

It's just two calls to ops->gone_insecure(), one at the end of
disconnect_context() and one when OTRL_TLV_DISCONNECTED is received,
corresponding to the only two calls of otrl_context_force_finished I
could find (first one through otrl_context_force_plaintext).

Tested with bitlbee-otr and it works.

The patch is attached to this email, and also available in the
"gone_insecure" branch of my github fork [2]

[1]: https://bugs.otr.im/issues/48
[2]: https://github.com/dequis/libotr/tree/gone_insecure
From 9c42fcfbb085542ab9dab719a988c63c2a01f917 Mon Sep 17 00:00:00 2001
From: dequis <[email protected]>
Date: Sat, 6 Jun 2015 03:39:23 -0300
Subject: [PATCH] Fix: call gone_insecure op when disconnecting or disconnected

Fixes #48
---
 src/message.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/message.c b/src/message.c
index fd12257..44d7f0a 100644
--- a/src/message.c
+++ b/src/message.c
@@ -1366,6 +1366,10 @@ int otrl_message_receiving(OtrlUserState us, const OtrlMessageAppOps *ops,
 		     * don't try sending anything else to him. */
 		    if (otrl_tlv_find(tlvs, OTRL_TLV_DISCONNECTED)) {
 			otrl_context_force_finished(context);
+
+			if (ops->gone_insecure) {
+			    ops->gone_insecure(opdata, context);
+			}
 		    }
 
 		    /* If the other side told us to use the current
@@ -1881,6 +1885,9 @@ static void disconnect_context(OtrlUserState us, const OtrlMessageAppOps *ops,
     if (ops->update_context_list) {
 	ops->update_context_list(opdata);
     }
+    if (ops->gone_insecure) {
+	ops->gone_insecure(opdata, context);
+    }
 }
 
 
-- 
2.0.0+fc2

_______________________________________________
OTR-dev mailing list
[email protected]
http://lists.cypherpunks.ca/mailman/listinfo/otr-dev

Reply via email to