[glib-networking/mcatanzaro/#15] gnutls: discard queued data after interrupted writes



commit b099ed837c07c228c9d3d4a8e161089b68988bbb
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Sun Aug 18 21:42:32 2019 -0500

    gnutls: discard queued data after interrupted writes
    
    If a write is interrupted, GnuTLS buffers the data in order to send it
    again during the next write. E.g. you can call gnutls_write() with NULL
    data and 0 size to resend the buffered data, or you can call it again
    with exactly the same parameters, and either way will be fine. But
    GOutputStream works differently. Applications using GOutputStream expect
    they need to explicitly resend any data that wasn't queued and expect to
    be able to resend different data if they so choose.
    
    Per Dan:
    
    """
    GTlsOutputStreamGnutls is violating the semantics of GOutputStream; if
    it claims to have not written the data, then it can't write it later
    without being asked to. GTlsConnectionGnutls needs to hide this behavior
    from higher levels somehow.
    """
    
    Fixes #15

 tls/gnutls/gtlsconnection-gnutls.c | 3 +++
 1 file changed, 3 insertions(+)
---
diff --git a/tls/gnutls/gtlsconnection-gnutls.c b/tls/gnutls/gtlsconnection-gnutls.c
index 4e883a7..8307139 100644
--- a/tls/gnutls/gtlsconnection-gnutls.c
+++ b/tls/gnutls/gtlsconnection-gnutls.c
@@ -1020,6 +1020,9 @@ g_tls_connection_gnutls_write (GTlsConnectionBase  *tls,
   ret = gnutls_record_send (priv->session, buffer, count);
   END_GNUTLS_IO (gnutls, G_IO_OUT, ret, status, _("Error writing data to TLS socket"), error);
 
+  if (ret == GNUTLS_E_INTERRUPTED || ret == GNUTLS_E_AGAIN)
+    gnutls_record_discard_queued (priv->session);
+
   *nwrote = MAX (ret, 0);
   return status;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]