Fix invalid read when a connection fails

Review Request #3275 — Created June 27, 2024 and submitted

Information

ibis/ibis
default

Reviewers

ibis_client_disconnect takes ownership of error so it must not be cleared here.

Ran Pidgin in valgrind with a successful and unsuccessful connection to a local ergo server.

Summary ID
Fix invalid read when a connection fails
204c6f0e3ba1ee6a4cd182e4e57a2add7276a9bd
ivanhoe
  1. 
      
  2. I got this invalid read when trying and failing to connect to a local ergo server due to TLS not being supported:

    ==1078898== Invalid read of size 4
    ==1078898==    at 0x493CB8F: g_error_free (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.8000.2)
    ==1078898==    by 0x493D0C9: g_clear_error (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.8000.2)
    ==1078898==    by 0xFE24F5B: ibis_client_finalize (ibisclient.c:310)
    ==1078898==    by 0x4D4D2C2: g_object_unref (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.8000.2)
    ==1078898==    by 0xFE03EFB: purple_ircv3_connection_disconnect (purpleircv3connection.c:508)
    ==1078898==    by 0x4C7E716: purple_connection_disconnect (connection.c:843)
    ==1078898==    by 0x4C7D587: purple_connection_disconnect_cb (connection.c:322)
    ==1078898==    by 0x4956BDD: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.8000.2)
    ==1078898==    by 0x4953E3E: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.8000.2)
    ==1078898==    by 0x4955EC6: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.8000.2)
    ==1078898==    by 0x49564DF: g_main_context_iteration (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.8000.2)
    ==1078898==    by 0x58BC48C: g_application_run (in /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.8000.2)
    ==1078898==  Address 0x203a0160 is 0 bytes inside a block of size 16 free'd
    ==1078898==    at 0x48431EF: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==1078898==    by 0x493CC40: g_error_free (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.8000.2)
    ==1078898==    by 0x493D0C9: g_clear_error (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.8000.2)
    ==1078898==    by 0xFE24C51: ibis_client_connect_cb (ibisclient.c:259)
    ==1078898==    by 0x588C6E2: ??? (in /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.8000.2)
    ==1078898==    by 0x588D382: ??? (in /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.8000.2)
    ==1078898==    by 0x5883774: ??? (in /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.8000.2)
    ==1078898==    by 0x588C6E2: ??? (in /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.8000.2)
    ==1078898==    by 0x588D382: ??? (in /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.8000.2)
    ==1078898==    by 0x58710BB: ??? (in /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.8000.2)
    ==1078898==    by 0x588C6E2: ??? (in /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.8000.2)
    ==1078898==    by 0x588C71C: ??? (in /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.8000.2)
    ==1078898==  Block was alloc'd at
    ==1078898==    at 0x4840808: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==1078898==    by 0x495CDD1: g_malloc (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.8000.2)
    ==1078898==    by 0x497758C: g_slice_alloc0 (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.8000.2)
    ==1078898==    by 0x493C4EB: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.8000.2)
    ==1078898==    by 0x493CAC0: g_error_new_literal (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.8000.2)
    ==1078898==    by 0x493D02B: g_set_error_literal (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.8000.2)
    ==1078898==    by 0x3145B724: ??? (in /usr/lib/x86_64-linux-gnu/gio/modules/libgiognutls.so)
    ==1078898==    by 0x3145C3CE: ??? (in /usr/lib/x86_64-linux-gnu/gio/modules/libgiognutls.so)
    ==1078898==    by 0x314622E1: ??? (in /usr/lib/x86_64-linux-gnu/gio/modules/libgiognutls.so)
    ==1078898==    by 0x314625A1: ??? (in /usr/lib/x86_64-linux-gnu/gio/modules/libgiognutls.so)
    ==1078898==    by 0x588D4C0: ??? (in /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.8000.2)
    ==1078898==    by 0x4984711: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.8000.2)
    
  3. 
      
grim
  1. Great find! Thanks!!

  2. 
      
grim
Review request changed
Status:
Completed