dtlsconnection: Ignore OpenSSL system call errors
authorOlivier CrĂȘte <olivier.crete@collabora.com>
Mon, 5 Oct 2020 20:40:55 +0000 (16:40 -0400)
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Sat, 10 Oct 2020 15:34:21 +0000 (15:34 +0000)
OpenSSL shouldn't be making real system calls, so we can safely
ignore syscall errors. System interactions should happen through
our BIO. So especially don't look at the system's errno, as it
should be meaningless.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1656>

ext/dtls/gstdtlsconnection.c

index 0e80235..22e0132 100644 (file)
@@ -1001,35 +1001,13 @@ handle_error (GstDtlsConnection * self, int ret, GstResourceError error_type,
     case SSL_ERROR_WANT_WRITE:
       GST_LOG_OBJECT (self, "SSL wants write");
       return GST_FLOW_OK;
-    case SSL_ERROR_SYSCALL:{
-      gchar message[1024] = "<unknown>";
-      gint syserror;
-#ifdef G_OS_WIN32
-      syserror = WSAGetLastError ();
-      FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, syserror, 0, message,
-          sizeof message, NULL);
-#else
-      syserror = errno;
-      strerror_r (syserror, message, sizeof message);
-#endif
-
-      if (syserror == 0) {
-        GST_TRACE_OBJECT (self, "No error");
-        return GST_FLOW_OK;
-      } else {
-        GST_ERROR_OBJECT (self, "Fatal SSL syscall error: errno %d: %s",
-            syserror, message);
-        if (err)
-          *err =
-              g_error_new (GST_RESOURCE_ERROR, error_type,
-              "Fatal SSL syscall error: errno %d: %s", syserror, message);
-        if (self->priv->connection_state != GST_DTLS_CONNECTION_STATE_FAILED) {
-          self->priv->connection_state = GST_DTLS_CONNECTION_STATE_FAILED;
-          *notify_state = TRUE;
-        }
-        return GST_FLOW_ERROR;
-      }
-    }
+    case SSL_ERROR_SYSCALL:
+      /* OpenSSL shouldn't be making real system calls, so we can safely
+       * ignore syscall errors. System interactions should happen through
+       * our BIO.
+       */
+      GST_DEBUG_OBJECT (self, "OpenSSL reported a syscall error, ignoring.");
+      return GST_FLOW_OK;
     default:
       if (self->priv->connection_state != GST_DTLS_CONNECTION_STATE_FAILED) {
         self->priv->connection_state = GST_DTLS_CONNECTION_STATE_FAILED;