[vlc-devel] [PATCH 3.0] contrib: gnutls: Don't use function introduced in Windows Vista

Steve Lhomme robux4 at ycbcr.xyz
Wed May 19 11:24:34 UTC 2021


LGTM

On 2021-05-18 18:17, Hugo Beauzée-Luyssen wrote:
> Fix #25746
> ---
>   ...hen-compiling-for-versions-older-tha.patch | 67 +++++++++++++++++++
>   contrib/src/gnutls/rules.mak                  |  3 +
>   2 files changed, 70 insertions(+)
>   create mode 100644 contrib/src/gnutls/0001-stat-fstat-Fix-when-compiling-for-versions-older-tha.patch
> 
> diff --git a/contrib/src/gnutls/0001-stat-fstat-Fix-when-compiling-for-versions-older-tha.patch b/contrib/src/gnutls/0001-stat-fstat-Fix-when-compiling-for-versions-older-tha.patch
> new file mode 100644
> index 0000000000..f4dc05d3f3
> --- /dev/null
> +++ b/contrib/src/gnutls/0001-stat-fstat-Fix-when-compiling-for-versions-older-tha.patch
> @@ -0,0 +1,67 @@
> +From 1796cda9975bd459a87222676030b943869c686e Mon Sep 17 00:00:00 2001
> +From: Bruno Haible <bruno at clisp.org>
> +Date: Wed, 16 Sep 2020 23:51:52 +0200
> +Subject: [PATCH] stat, fstat: Fix when compiling for versions older than
> + Windows Vista.
> +
> +Reported by Eli Zaretskii <eliz at gnu.org> in
> +<https://lists.gnu.org/archive/html/bug-gnulib/2020-09/msg00027.html>.
> +
> +* lib/stat-w32.c: Include <sdkddkver.h>. Test the value of _WIN32_WINNT
> +that was originally set before we redefined it.
> +* m4/stat.m4 (gl_PREREQ_STAT_W32): New macro.
> +(gl_PREREQ_STAT): Require it.
> +* m4/fstat.m4 (gl_PREREQ_FSTAT): Likewise.
> +---
> + gnutls/gl/stat-w32.c | 24 ++++++++++++++++++------
> + 4 files changed, 43 insertions(+), 8 deletions(-)
> +
> +diff --git gnutls/gl/lib/stat-w32.c gnutls/gl/lib/stat-w32.c
> +index 19bdfaa37..72442e933 100644
> +--- gnutls/gl/stat-w32.c
> ++++ gnutls/gl/stat-w32.c
> +@@ -20,10 +20,22 @@
> +
> + #if defined _WIN32 && ! defined __CYGWIN__
> +
> +-/* Ensure that <windows.h> defines FILE_ID_INFO.  */
> +-#if !defined _WIN32_WINNT || (_WIN32_WINNT < _WIN32_WINNT_WIN8)
> +-# undef _WIN32_WINNT
> +-# define _WIN32_WINNT _WIN32_WINNT_WIN8
> ++/* Attempt to make <windows.h> define FILE_ID_INFO.
> ++   But ensure that the redefinition of _WIN32_WINNT does not make us assume
> ++   Windows Vista or newer when building for an older version of Windows.  */
> ++#if HAVE_SDKDDKVER_H
> ++# include <sdkddkver.h>
> ++# if _WIN32_WINNT >= _WIN32_WINNT_VISTA
> ++#  define WIN32_ASSUME_VISTA 1
> ++# else
> ++#  define WIN32_ASSUME_VISTA 0
> ++# endif
> ++# if !defined _WIN32_WINNT || (_WIN32_WINNT < _WIN32_WINNT_WIN8)
> ++#  undef _WIN32_WINNT
> ++#  define _WIN32_WINNT _WIN32_WINNT_WIN8
> ++# endif
> ++#else
> ++# define WIN32_ASSUME_VISTA (_WIN32_WINNT >= _WIN32_WINNT_VISTA)
> + #endif
> +
> + #include <sys/types.h>
> +@@ -46,7 +58,7 @@
> + #undef GetFinalPathNameByHandle
> + #define GetFinalPathNameByHandle GetFinalPathNameByHandleA
> +
> +-#if !(_WIN32_WINNT >= _WIN32_WINNT_VISTA)
> ++#if !WIN32_ASSUME_VISTA
> +
> + /* Avoid warnings from gcc -Wcast-function-type.  */
> + # define GetProcAddress \
> +@@ -149,7 +161,7 @@ _gl_fstat_by_handle (HANDLE h, const char *path, struct stat *buf)
> +   DWORD type = GetFileType (h);
> +   if (type == FILE_TYPE_DISK)
> +     {
> +-#if !(_WIN32_WINNT >= _WIN32_WINNT_VISTA)
> ++#if !WIN32_ASSUME_VISTA
> +       if (!initialized)
> +         initialize ();
> + #endif
> diff --git a/contrib/src/gnutls/rules.mak b/contrib/src/gnutls/rules.mak
> index e425f5f9a6..70bd94c64f 100644
> --- a/contrib/src/gnutls/rules.mak
> +++ b/contrib/src/gnutls/rules.mak
> @@ -31,6 +31,9 @@ gnutls: gnutls-$(GNUTLS_VERSION).tar.xz .sum-gnutls
>   	# forbidden RtlSecureZeroMemory call in winstore builds
>   	$(APPLY) $(SRC)/gnutls/0001-explicit_bzero-Do-not-call-SecureZeroMemory-on-UWP-b.patch
>   
> +	# Don't use functions available starting with windows vista
> +	$(APPLY) $(SRC)/gnutls/0001-stat-fstat-Fix-when-compiling-for-versions-older-tha.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
>   
> -- 
> 2.30.2
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
> 


More information about the vlc-devel mailing list