otrv4 / pidgin-otrng

Fork of https://bugs.otr.im/plugins/pidgin-otr. This is a mirror of https://bugs.otr.im/otrv4/pidgin-otrng
GNU General Public License v2.0
16 stars 5 forks source link

Crash when participant Alice stops OTR conversation with Bob and Bob stops OTR as well #57

Closed DrWhax closed 5 years ago

DrWhax commented 6 years ago
*** Error in `pidgin': double free or corruption (out): 0x00005ff2744195e0 ***                                                                                                                   
======= Backtrace: =========                                                                                                                                                                     
/lib/x86_64-linux-gnu/libc.so.6(+0x70bfb)[0x77021289ebfb]                                                                                                                                        
/lib/x86_64-linux-gnu/libc.so.6(+0x76fc6)[0x7702128a4fc6]                                                                                                                                        
/lib/x86_64-linux-gnu/libc.so.6(+0x7780e)[0x7702128a580e]                                                                                                                                        
/usr/local/lib/pidgin/pidgin-otrng.so(otrng_plugin_conversation_free+0x25)[0x77020a5f4245]                                                                                                       
/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0(g_closure_invoke+0x145)[0x770213ffaf75]                                                                                                            
/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0(+0x21f82)[0x77021400cf82]                                                                                                                          
/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0(g_signal_emit_valist+0xe3c)[0x770214015bdc]                                                                                                        
/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0(g_signal_emit+0x8f)[0x770214015fbf]                                                                                                                
/usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0(gtk_widget_activate+0x6e)[0x77021589e62e]                                                                                                          
/usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0(gtk_menu_shell_activate_item+0xfd)[0x7702157994dd]                                                                                                 
/usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0(+0x143846)[0x770215799846]                                                                                                                         
/usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0(+0x1317bc)[0x7702157877bc]                                                                                                                         
/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0(g_closure_invoke+0x145)[0x770213ffaf75]                                                                                                            
/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0(+0x2237d)[0x77021400d37d]                                                                                                                          
/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0(g_signal_emit_valist+0x8df)[0x77021401567f]                                                                                                        
/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0(g_signal_emit+0x8f)[0x770214015fbf]                                                                                                                
/usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0(+0x2498ac)[0x77021589f8ac]                                                                                                                         
/usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0(gtk_propagate_event+0xc4)[0x770215785f84]                                                                                                          
/usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0(gtk_main_do_event+0x2cb)[0x77021578633b]                                                                                                           
/usr/lib/x86_64-linux-gnu/libgdk-x11-2.0.so.0(+0x5acbc)[0x7702153fbcbc]                                                                                                                          
/lib/x86_64-linux-gnu/libglib-2.0.so.0(g_main_context_dispatch+0x2a7)[0x770213d217f7]                                                                                                            
/lib/x86_64-linux-gnu/libglib-2.0.so.0(+0x4aa60)[0x770213d21a60]                                                                                                                                 
/lib/x86_64-linux-gnu/libglib-2.0.so.0(g_main_loop_run+0xc2)[0x770213d21d82]                                                                                                                     
/usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0(gtk_main+0xb7)[0x7702157853b7]                                                                                                                     
pidgin(main+0xc4b)[0x5ff271bf500b]                                                                                                                                                               
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf1)[0x77021284e2e1]                                                                                                                          
pidgin(_start+0x2a)[0x5ff271bf52ea]                                                                                                                                                              
claucece commented 6 years ago

Hey!

What do you mean by stops? Is it when the private conversation is ended?

DrWhax commented 6 years ago

Hey!

Let's say i'm Alice and I start an OTR conversation with Bob. I speak a line and Bob then cancels the OTR conversation with me and subsequently, I stop the otr conversation as well, nothing happens, if I redo the stop operation, Pidgin crashes with the above crash.

Is this more clear?

claucece commented 6 years ago

Yes! Thanks @DrWhax

olabini commented 5 years ago

Need to investigate.

claucece commented 5 years ago

Hey!

Ok, I have checked this and it happens this way:

'Attempting to start a private conversation
Unverified conversation started.  Your client is not logging this conversation.

On Bob screen, it shows up:

Unverified conversation started.  Your client is not logging this conversation.
claucece commented 5 years ago

OTR debug says this when the crash happens:

Assertion failed: (protocol != NULL), function protocol_and_account_to_client_id, file pidgin-helpers.c, line 37.
claucece commented 5 years ago

Another crash, that I found out is this:

Hey!

Ok, I have checked this and it happens this way:

'Attempting to start a private conversation
Unverified conversation started.  Your client is not logging this conversation.
Unverified conversation started.  Your client is not logging this conversation.
MauroVelasco commented 5 years ago

Hey!

Ok, I have checked this and it happens this way:

* Alice logs in to pidgin

* Bob logs in to pidgin

* Alice starts an OTR conversation with Bob. These messages show up:
'Attempting to start a private conversation
Unverified conversation started.  Your client is not logging this conversation.

On Bob screen, it shows up:

Unverified conversation started.  Your client is not logging this conversation.
* Alice types 'Hey, Bob'. Bob receives it successfully.

* Bob types 'Hey, Alice'. Alice receives it successfully.

* Alice ends the conversation by clicking on 'End private conversation' button. This message is show in both Alice and Bob screens 'Private conversation lost.'

* On Bob's menu, there is still the possibility of clicking on 'End private conversation', if you do, nothing happens. On the second time you click it, pidgin crashes.

Hey,

I guess the "End private conversation" on Alice, must be disabled, when Bob press "End private conversation", in that way Alice will not be able to press "End private conversation" (neither Bob of course).

I found the condition which control this behavior:

gtk_widget_set_sensitive(GTK_WIDGET(end), !insecure || finished);

on gtk-dialog.c/otr_set_menu_labels

As the enable/disable condition is handled by gtk_widget_set_sensitive (* widget , TRUE -> enabled , FALSE -> disabled), the option "End private conversation" is keep enabled because the condition: !insecure || finished (is evaluated as TRUE)

if we change the condition to:

gtk_widget_set_sensitive(GTK_WIDGET(end), !insecure || !finished);

Then Alice end is disabled, but Bob end is enabled.

The solution could be find a condition which evaluates every end and set the parameter 0 (false) to get the element disabled.

claucece commented 5 years ago

Hi, @MauroVelasco !

Very interesting. I see that the finished bool is set up by the 'TRUST_FINISHED' constant. This latter const is set up here: https://github.com/otrv4/pidgin-otrng/blob/master/plugin-all.c#L1195. That code calls this function otrng_conversation_is_finished, which is defined in the libotr-ng library here: https://github.com/otrv4/libotr-ng/blob/master/src/client.c#L180. In the case of OTRv4, that function returns a true boolean if the state is OTRNG_STATE_FINISHED, which is the case, as per the protocol, you receive a TLV type 1 ("If you receive a TLV record of this type, you should transition to 'FINISHED' state (see below), and inform the participant that its correspondent has closed its end of the private connection, and the participant should do the same."). For some reason, though, it does not seem to be working. I will check more; but you can also look into it ;)

MauroVelasco commented 5 years ago

Hey @claucece, attached the functions involved:

issue57GraphFlow

I'll look more in detail about state transition.

MauroVelasco commented 5 years ago

Hi @claucece,

Looks like this condition do the trick:

gtk_widget_set_sensitive(GTK_WIDGET(end), !(insecure || finished) );

In this way both ends are disabled once the conversation is finished.

Disabled1 disabled2

MauroVelasco commented 5 years ago

Hi @claucece, related to the other issue, looks like the session can't be validated:

pidgin_expire_time_issue

claucece commented 5 years ago

Hi, @MauroVelasco

Thanks for the diagram! It looks very nice. But that seems to be mostly for when an user asks to disconnect; not when the user receives a disconnect request. So let's look together at that case later.

Looks like this condition do the trick: gtk_widget_set_sensitive(GTK_WIDGET(end), !(insecure || finished) );

Yeah.. but I don't think we should change it as it should be !insecure but finished.. let's look together at this ;)

claucece commented 5 years ago

So, around the other issue.. mmm.. it is interesting.. it looks like the session is getting expired for some reason..

MauroVelasco commented 5 years ago

So, around the other issue.. mmm.. it is interesting.. it looks like the session is getting expired for some reason..

Yes, exactly, I believe some value in the conversation parameter is NULL then the validation fails and explode. But I'll verify.