[glib-openssl] Fix readwrite after close



commit f54ffb5f6c002ecba84e14bcb01bbd720a33b598
Author: Ignacio Casal Quinteiro <qignacio amazon com>
Date:   Wed Sep 19 11:11:36 2018 +0200

    Fix readwrite after close

 tls/base/gtlsinputstream-base.c  | 9 ++++++++-
 tls/base/gtlsoutputstream-base.c | 9 ++++++++-
 2 files changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/tls/base/gtlsinputstream-base.c b/tls/base/gtlsinputstream-base.c
index 3438a11..6f257de 100644
--- a/tls/base/gtlsinputstream-base.c
+++ b/tls/base/gtlsinputstream-base.c
@@ -23,6 +23,8 @@
 #include "config.h"
 #include "gtlsinputstream-base.h"
 
+#include <glib/gi18n.h>
+
 static void g_tls_input_stream_base_pollable_iface_init (GPollableInputStreamInterface *iface);
 
 G_DEFINE_TYPE_WITH_CODE (GTlsInputStreamBase, g_tls_input_stream_base, G_TYPE_INPUT_STREAM,
@@ -66,7 +68,12 @@ g_tls_input_stream_base_read (GInputStream  *stream,
   gssize ret;
 
   conn = g_weak_ref_get (&tls_stream->priv->weak_conn);
-  g_return_val_if_fail (conn != NULL, -1);
+  if (conn == NULL)
+    {
+      g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_CLOSED,
+                           _("Connection is closed"));
+      return -1;
+    }
 
   ret = g_tls_connection_base_read (conn,
                                     buffer, count, TRUE,
diff --git a/tls/base/gtlsoutputstream-base.c b/tls/base/gtlsoutputstream-base.c
index d9bcf8e..8400efd 100644
--- a/tls/base/gtlsoutputstream-base.c
+++ b/tls/base/gtlsoutputstream-base.c
@@ -23,6 +23,8 @@
 #include "config.h"
 #include "gtlsoutputstream-base.h"
 
+#include <glib/gi18n.h>
+
 static void g_tls_output_stream_base_pollable_iface_init (GPollableOutputStreamInterface *iface);
 
 G_DEFINE_TYPE_WITH_CODE (GTlsOutputStreamBase, g_tls_output_stream_base, G_TYPE_OUTPUT_STREAM,
@@ -66,7 +68,12 @@ g_tls_output_stream_base_write (GOutputStream  *stream,
   gssize ret;
 
   conn = g_weak_ref_get (&tls_stream->priv->weak_conn);
-  g_return_val_if_fail (conn != NULL, -1);
+  if (conn == NULL)
+    {
+      g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_CLOSED,
+                           _("Connection is closed"));
+      return -1;
+    }
 
   ret = g_tls_connection_base_write (conn, buffer, count, TRUE,
                                      cancellable, error);


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