[mingw-crt] The memmove_s patch wasn't fully applied upstream
Erik van Pienbroek
epienbro at fedoraproject.org
Thu Jul 31 06:46:45 UTC 2014
commit c8648e1d96703592d656a2f5b925943b53c61148
Author: Erik van Pienbroek <epienbro at fedoraproject.org>
Date: Thu Jul 31 08:46:38 2014 +0200
The memmove_s patch wasn't fully applied upstream
add_memmove_s.patch | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++
mingw-crt.spec | 5 +++
2 files changed, 89 insertions(+), 0 deletions(-)
---
diff --git a/add_memmove_s.patch b/add_memmove_s.patch
new file mode 100644
index 0000000..8a19a5e
--- /dev/null
+++ b/add_memmove_s.patch
@@ -0,0 +1,84 @@
+From d51b0c6477f1ce5ca2cc0377be239339327fa252 Mon Sep 17 00:00:00 2001
+From: Ruben De Smet <ruben.de.smet at telenet.be>
+Date: Mon, 28 Jul 2014 21:15:57 +0200
+Subject: [PATCH] Add secapi wrapper for memmove_s
+
+---
+ mingw-w64-crt/Makefile.am | 1 +
+ mingw-w64-crt/Makefile.in | 73 ++++++++++++++++++++++++++++++++++-----
+ mingw-w64-crt/lib32/msvcrt.def.in | 2 +-
+ mingw-w64-crt/lib64/msvcrt.def.in | 2 +-
+ mingw-w64-crt/secapi/memmove_s.c | 60 ++++++++++++++++++++++++++++++++
+ 5 files changed, 128 insertions(+), 10 deletions(-)
+ create mode 100644 mingw-w64-crt/secapi/memmove_s.c
+
+diff --git a/mingw-w64-crt/secapi/memmove_s.c b/mingw-w64-crt/secapi/memmove_s.c
+new file mode 100644
+index 0000000..a7b8501
+--- /dev/null
++++ b/mingw-w64-crt/secapi/memmove_s.c
+@@ -0,0 +1,60 @@
++#include <windows.h>
++#include <malloc.h>
++#include <errno.h>
++#include <msvcrt.h>
++
++errno_t __cdecl memmove_s (void *, size_t, const void *, size_t);
++static errno_t __cdecl _int_memmove_s (void *, size_t, const void *, size_t);
++static errno_t __cdecl _stub (void *, size_t, const void *, size_t);
++
++errno_t __cdecl (*__MINGW_IMP_SYMBOL(memmove_s))(void *, size_t, const void *, size_t) =
++ _stub;
++
++static errno_t __cdecl
++_stub (void *d, size_t dn, const void *s, size_t n)
++{
++ errno_t __cdecl (*f)(void *, size_t, const void *, size_t) = __MINGW_IMP_SYMBOL(memmove_s);
++
++ if (f == _stub)
++ {
++ f = (errno_t __cdecl (*)(void *, size_t, const void *, size_t))
++ GetProcAddress (__mingw_get_msvcrt_handle (), "memmove_s");
++ if (!f)
++ f = _int_memmove_s;
++ __MINGW_IMP_SYMBOL(memmove_s) = f;
++ }
++ return (*f)(d, dn, s, n);
++}
++
++errno_t __cdecl
++memmove_s (void *d, size_t dn, const void *s, size_t n)
++{
++ return _stub (d, dn, s, n);
++}
++
++static errno_t __cdecl
++_int_memmove_s (void *d, size_t dn, const void *s, size_t n)
++{
++ if (!n)
++ return 0;
++
++ if (!d || !s)
++ {
++ if (d)
++ memset (d, 0, dn);
++ errno = EINVAL;
++ return EINVAL;
++ }
++
++ if (dn < n)
++ {
++ memset (d, 0, dn);
++
++ errno = ERANGE;
++ return ERANGE;
++ }
++
++ memmove (d, s, n);
++
++ return 0;
++}
+--
+1.8.3.1
+
+
diff --git a/mingw-crt.spec b/mingw-crt.spec
index 4c5d68e..fe68b26 100644
--- a/mingw-crt.spec
+++ b/mingw-crt.spec
@@ -24,6 +24,9 @@ Source0: http://sourceforge.net/code-snapshots/git/m/mi/mingw-w64/mingw-w
Source0: http://downloads.sourceforge.net/mingw-w64/mingw-w64-v%{version}.tar.bz2
%endif
+# Upstream commit ec1ff7764fbea4eefbb290c9ba888af3386ede8e is incomplete
+Patch0: add_memmove_s.patch
+
BuildArch: noarch
BuildRequires: mingw32-filesystem >= 95
@@ -71,6 +74,8 @@ unzip %{S:0}
%setup -q -n mingw-w64-v%{version}
%endif
+%patch0 -p1
+
%build
pushd mingw-w64-crt
More information about the scm-commits
mailing list