From ef6ae47b8bf971d3f2803b1552b7debc59429dc1 Mon Sep 17 00:00:00 2001 From: dequis Date: Thu, 22 Mar 2018 21:31:08 -0300 Subject: Fix "Failed to read fixed header" with TLS 1.3 Thanks to mandree for noticing it's EAGAIN See bug 410 for details --- patches/13-async-sockets-are-hard.patch | 51 +++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 patches/13-async-sockets-are-hard.patch diff --git a/patches/13-async-sockets-are-hard.patch b/patches/13-async-sockets-are-hard.patch new file mode 100644 index 0000000..6575294 --- /dev/null +++ b/patches/13-async-sockets-are-hard.patch @@ -0,0 +1,51 @@ +--- a/libpurple/protocols/facebook/mqtt.c ++++ b/libpurple/protocols/facebook/mqtt.c +@@ -361,26 +361,33 @@ + g_byte_array_set_size(priv->rbuf, 0); + + res = purple_ssl_read(priv->gsc, &byte, sizeof byte); +- g_byte_array_append(priv->rbuf, &byte, sizeof byte); + +- if (res != sizeof byte) { ++ if (res < 0 && errno == EAGAIN) { ++ return; ++ } else if (res != 1) { + fb_mqtt_error(mqtt, FB_MQTT_ERROR_GENERAL, + _("Failed to read fixed header")); + return; + } + ++ g_byte_array_append(priv->rbuf, &byte, sizeof byte); ++ + mult = 1; + + do { + res = purple_ssl_read(priv->gsc, &byte, sizeof byte); +- g_byte_array_append(priv->rbuf, &byte, sizeof byte); + +- if (res != sizeof byte) { ++ /* TODO: this case isn't handled yet */ ++ if (0 && res < 0 && errno == EAGAIN) { ++ return; ++ } else if (res != 1) { + fb_mqtt_error(mqtt, FB_MQTT_ERROR_GENERAL, + _("Failed to read packet size")); + return; + } + ++ g_byte_array_append(priv->rbuf, &byte, sizeof byte); ++ + priv->remz += (byte & 127) * mult; + mult *= 128; + } while ((byte & 128) != 0); +@@ -390,7 +397,9 @@ + size = MIN(priv->remz, sizeof buf); + rize = purple_ssl_read(priv->gsc, buf, size); + +- if (rize < 1) { ++ if (rize < 0 && errno == EAGAIN) { ++ return; ++ } else if (rize < 1) { + fb_mqtt_error(mqtt, FB_MQTT_ERROR_GENERAL, + _("Failed to read packet data")); + return; -- cgit v1.2.3