From 9ce0a4fd28acaa249b7a4f2f132416dd8448e586 Mon Sep 17 00:00:00 2001 From: dequis Date: Mon, 9 May 2016 21:01:18 -0300 Subject: mqtt: Fix double free on ssl handshake failures Normally, bitlbee's ssl_handshake calls the callback with an error status and calls ssl_disconnect(). In this plugin fb_mqtt_error(), calls fb_mqtt_close(), which called ssl_disconnect() on priv->ssl. This fix prevents that double ssl_disconnect() by setting priv->ssl to null, so that fb_mqtt_close() cleans everything except that. Fixes #82 --- facebook/facebook-mqtt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/facebook/facebook-mqtt.c b/facebook/facebook-mqtt.c index 8549a1c..9610bbd 100644 --- a/facebook/facebook-mqtt.c +++ b/facebook/facebook-mqtt.c @@ -565,6 +565,9 @@ fb_mqtt_cb_open(gpointer data, gint error, gpointer ssl, gint fd; if ((ssl == NULL) || (error != SSL_OK)) { + /* Set this to null to avoid freeing it in fb_mqtt_close() */ + priv->ssl = NULL; + fb_mqtt_error(mqtt, FB_MQTT_ERROR_GENERAL, "Failed to connect"); return FALSE; } -- cgit v1.2.3 From 0877cf236761eaefcd61b8fd5722272ffe1f12c5 Mon Sep 17 00:00:00 2001 From: dequis Date: Mon, 16 May 2016 02:12:20 -0300 Subject: Store sent message id in lastmid, to deduplicate echoed messages Mostly fixes bug #76 This is crappy and error prone, just like the rest of the duplicate message handling code. It works, but it's going to get some echoes now and then, particularly in quick moving groupchats. I'm pretty sure this is a bug in the server, but the official clients have much more elaborate deduplication built-in, so they won't notice. --- facebook/facebook-api.c | 1 + 1 file changed, 1 insertion(+) diff --git a/facebook/facebook-api.c b/facebook/facebook-api.c index 3ddfa70..c8e5e30 100644 --- a/facebook/facebook-api.c +++ b/facebook/facebook-api.c @@ -2115,6 +2115,7 @@ fb_api_message_send(FbApi *api, FbApiMessage *msg) JsonBuilder *bldr; mid = FB_API_MSGID(g_get_real_time() / 1000, g_random_int()); + priv->lastmid = mid; if (msg->tid != 0) { tpfx = "tfbid_"; -- cgit v1.2.3