[vlc-devel] [PATCH 2/2] contrib: gnutls: fix GetHandleInformation call forbidden in Winstore builds

Steve Lhomme robux4 at ycbcr.xyz
Thu Jun 4 17:09:45 CEST 2020


This part of the gnulib code is never used anyway in Winstore builds. It's
only used for linux random number generation.
---
 ...l-GetHandleInformation-in-Winstore-a.patch | 41 +++++++++++++++++++
 contrib/src/gnutls/rules.mak                  |  1 +
 2 files changed, 42 insertions(+)
 create mode 100644 contrib/src/gnutls/0001-fcntl-do-not-call-GetHandleInformation-in-Winstore-a.patch

diff --git a/contrib/src/gnutls/0001-fcntl-do-not-call-GetHandleInformation-in-Winstore-a.patch b/contrib/src/gnutls/0001-fcntl-do-not-call-GetHandleInformation-in-Winstore-a.patch
new file mode 100644
index 000000000000..9175fbed2437
--- /dev/null
+++ b/contrib/src/gnutls/0001-fcntl-do-not-call-GetHandleInformation-in-Winstore-a.patch
@@ -0,0 +1,41 @@
+From 0c8ca1736ee07c7d7dbce05108120cf4f8937bd0 Mon Sep 17 00:00:00 2001
+From: Steve Lhomme <robux4 at ycbcr.xyz>
+Date: Thu, 4 Jun 2020 10:15:38 +0200
+Subject: [PATCH] fcntl: do not call GetHandleInformation() in Winstore apps
+
+The API is forbidden [1] and HANDLE_FLAG_INHERIT would never be set as exec()
+is not allowed either [2].
+
+[1] https://docs.microsoft.com/en-us/windows/win32/api/handleapi/nf-handleapi-gethandleinformation
+[2] https://docs.microsoft.com/en-us/cpp/cppcx/crt-functions-not-supported-in-universal-windows-platform-apps
+---
+ gl/fcntl.c | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+diff --git a/gl/fcntl.c b/gl/fcntl.c
+index 6b9927ec4..e316ca306 100644
+--- a/gl/fcntl.c
++++ b/gl/fcntl.c
+@@ -229,12 +229,19 @@ fcntl (int fd, int action, /* arg */...)
+       {
+ # if defined _WIN32 && ! defined __CYGWIN__
+         HANDLE handle = (HANDLE) _get_osfhandle (fd);
++#  if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP)
+         DWORD flags;
+         if (handle == INVALID_HANDLE_VALUE
+             || GetHandleInformation (handle, &flags) == 0)
+           errno = EBADF;
+         else
+           result = (flags & HANDLE_FLAG_INHERIT) ? 0 : FD_CLOEXEC;
++#  else /* ! WINAPI_PARTITION_DESKTOP */
++        if (handle == INVALID_HANDLE_VALUE)
++          errno = EBADF;
++        else
++          result = 0;
++#  endif /* ! WINAPI_PARTITION_DESKTOP */
+ # else /* !W32 */
+         /* Use dup2 to reject invalid file descriptors.  No way to
+            access this information, so punt.  */
+--
+2.26.0.windows.1
+
diff --git a/contrib/src/gnutls/rules.mak b/contrib/src/gnutls/rules.mak
index 7db4a149952b..9f329e70d828 100644
--- a/contrib/src/gnutls/rules.mak
+++ b/contrib/src/gnutls/rules.mak
@@ -20,6 +20,7 @@ $(TARBALLS)/gnutls-$(GNUTLS_VERSION).tar.xz:
 gnutls: gnutls-$(GNUTLS_VERSION).tar.xz .sum-gnutls
 	$(UNPACK)
 	$(APPLY) $(SRC)/gnutls/gnutls-fix-mangling.patch
+	$(APPLY) $(SRC)/gnutls/0001-fcntl-do-not-call-GetHandleInformation-in-Winstore-a.patch
 	# disable the dllimport in static linking (pkg-config --static doesn't handle Cflags.private)
 	cd $(UNPACK_DIR) && sed -i.orig -e s/"_SYM_EXPORT __declspec(dllimport)"/"_SYM_EXPORT"/g lib/includes/gnutls/gnutls.h.in
 ifdef HAVE_ANDROID
-- 
2.26.2



More information about the vlc-devel mailing list