Hi, Attached patch fixes a compatibility issue with p11-kit and sigar on Windows XP (missing strerror_s symbol). Okay to commit?
Regards, Erik van Pienbroek
>From aa643f570cd1cb7c515af405fd844aab3c69ab45 Mon Sep 17 00:00:00 2001 From: Erik van Pienbroek <epien...@fedoraproject.org> Date: Fri, 28 Mar 2014 15:14:25 +0100 Subject: [PATCH] Add secapi wrapper for strerror_s --- mingw-w64-crt/Makefile.am | 1 + mingw-w64-crt/Makefile.in | 46 ++++++++++++++++++++++++++++++--- mingw-w64-crt/lib32/msvcrt.def.in | 2 +- mingw-w64-crt/lib64/msvcrt.def.in | 2 +- mingw-w64-crt/secapi/strerror_s.c | 54 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 99 insertions(+), 6 deletions(-) create mode 100644 mingw-w64-crt/secapi/strerror_s.c diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am index 271d2e7..4937840 100644 --- a/mingw-w64-crt/Makefile.am +++ b/mingw-w64-crt/Makefile.am @@ -181,6 +181,7 @@ src_msvcrt=\ secapi/memcpy_s.c \ secapi/rand_s.c \ secapi/sprintf_s.c \ + secapi/strerror_s.c \ secapi/vsprintf_s.c \ secapi/wmemcpy_s.c diff --git a/mingw-w64-crt/Makefile.in b/mingw-w64-crt/Makefile.in index 818610b..789b47d 100644 --- a/mingw-w64-crt/Makefile.in +++ b/mingw-w64-crt/Makefile.in @@ -1114,8 +1114,9 @@ am__lib32_libmsvcrt_a_SOURCES_DIST = misc/invalid_parameter_handler.c \ secapi/_waccess_s.c secapi/_wasctime_s.c secapi/_wctime32_s.c \ secapi/_wctime64_s.c secapi/_wstrtime_s.c secapi/_wmktemp_s.c \ secapi/_wstrdate_s.c secapi/asctime_s.c secapi/memcpy_s.c \ - secapi/rand_s.c secapi/sprintf_s.c secapi/vsprintf_s.c \ - secapi/wmemcpy_s.c misc/lc_locale_func.c lib32/msvcrt.def.in + secapi/rand_s.c secapi/sprintf_s.c secapi/strerror_s.c \ + secapi/vsprintf_s.c secapi/wmemcpy_s.c misc/lc_locale_func.c \ + lib32/msvcrt.def.in am__objects_20 = \ misc/lib32_libmsvcrt_a-invalid_parameter_handler.$(OBJEXT) \ misc/lib32_libmsvcrt_a-output_format.$(OBJEXT) \ @@ -1152,6 +1153,7 @@ am__objects_20 = \ secapi/lib32_libmsvcrt_a-memcpy_s.$(OBJEXT) \ secapi/lib32_libmsvcrt_a-rand_s.$(OBJEXT) \ secapi/lib32_libmsvcrt_a-sprintf_s.$(OBJEXT) \ + secapi/lib32_libmsvcrt_a-strerror_s.$(OBJEXT) \ secapi/lib32_libmsvcrt_a-vsprintf_s.$(OBJEXT) \ secapi/lib32_libmsvcrt_a-wmemcpy_s.$(OBJEXT) am__objects_21 = $(am__objects_20) \ @@ -2247,8 +2249,8 @@ am__lib64_libmsvcrt_a_SOURCES_DIST = misc/invalid_parameter_handler.c \ secapi/_waccess_s.c secapi/_wasctime_s.c secapi/_wctime32_s.c \ secapi/_wctime64_s.c secapi/_wstrtime_s.c secapi/_wmktemp_s.c \ secapi/_wstrdate_s.c secapi/asctime_s.c secapi/memcpy_s.c \ - secapi/rand_s.c secapi/sprintf_s.c secapi/vsprintf_s.c \ - secapi/wmemcpy_s.c lib64/msvcrt.def.in + secapi/rand_s.c secapi/sprintf_s.c secapi/strerror_s.c \ + secapi/vsprintf_s.c secapi/wmemcpy_s.c lib64/msvcrt.def.in am__objects_52 = \ misc/lib64_libmsvcrt_a-invalid_parameter_handler.$(OBJEXT) \ misc/lib64_libmsvcrt_a-output_format.$(OBJEXT) \ @@ -2285,6 +2287,7 @@ am__objects_52 = \ secapi/lib64_libmsvcrt_a-memcpy_s.$(OBJEXT) \ secapi/lib64_libmsvcrt_a-rand_s.$(OBJEXT) \ secapi/lib64_libmsvcrt_a-sprintf_s.$(OBJEXT) \ + secapi/lib64_libmsvcrt_a-strerror_s.$(OBJEXT) \ secapi/lib64_libmsvcrt_a-vsprintf_s.$(OBJEXT) \ secapi/lib64_libmsvcrt_a-wmemcpy_s.$(OBJEXT) @LIB64_TRUE@@W32API_FALSE@am_lib64_libmsvcrt_a_OBJECTS = \ @@ -3908,6 +3911,7 @@ src_msvcrt = \ secapi/memcpy_s.c \ secapi/rand_s.c \ secapi/sprintf_s.c \ + secapi/strerror_s.c \ secapi/vsprintf_s.c \ secapi/wmemcpy_s.c @@ -7044,6 +7048,8 @@ secapi/lib32_libmsvcrt_a-rand_s.$(OBJEXT): secapi/$(am__dirstamp) \ secapi/$(DEPDIR)/$(am__dirstamp) secapi/lib32_libmsvcrt_a-sprintf_s.$(OBJEXT): secapi/$(am__dirstamp) \ secapi/$(DEPDIR)/$(am__dirstamp) +secapi/lib32_libmsvcrt_a-strerror_s.$(OBJEXT): secapi/$(am__dirstamp) \ + secapi/$(DEPDIR)/$(am__dirstamp) secapi/lib32_libmsvcrt_a-vsprintf_s.$(OBJEXT): secapi/$(am__dirstamp) \ secapi/$(DEPDIR)/$(am__dirstamp) secapi/lib32_libmsvcrt_a-wmemcpy_s.$(OBJEXT): secapi/$(am__dirstamp) \ @@ -8642,6 +8648,8 @@ secapi/lib64_libmsvcrt_a-rand_s.$(OBJEXT): secapi/$(am__dirstamp) \ secapi/$(DEPDIR)/$(am__dirstamp) secapi/lib64_libmsvcrt_a-sprintf_s.$(OBJEXT): secapi/$(am__dirstamp) \ secapi/$(DEPDIR)/$(am__dirstamp) +secapi/lib64_libmsvcrt_a-strerror_s.$(OBJEXT): secapi/$(am__dirstamp) \ + secapi/$(DEPDIR)/$(am__dirstamp) secapi/lib64_libmsvcrt_a-vsprintf_s.$(OBJEXT): secapi/$(am__dirstamp) \ secapi/$(DEPDIR)/$(am__dirstamp) secapi/lib64_libmsvcrt_a-wmemcpy_s.$(OBJEXT): secapi/$(am__dirstamp) \ @@ -11020,6 +11028,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@secapi/$(DEPDIR)/lib32_libmsvcrt_a-memcpy_s.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@secapi/$(DEPDIR)/lib32_libmsvcrt_a-rand_s.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@secapi/$(DEPDIR)/lib32_libmsvcrt_a-sprintf_s.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@secapi/$(DEPDIR)/lib32_libmsvcrt_a-strerror_s.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@secapi/$(DEPDIR)/lib32_libmsvcrt_a-vsprintf_s.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@secapi/$(DEPDIR)/lib32_libmsvcrt_a-wmemcpy_s.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@secapi/$(DEPDIR)/lib64_libmsvcrt_a-_access_s.Po@am__quote@ @@ -11055,6 +11064,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@secapi/$(DEPDIR)/lib64_libmsvcrt_a-memcpy_s.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@secapi/$(DEPDIR)/lib64_libmsvcrt_a-rand_s.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@secapi/$(DEPDIR)/lib64_libmsvcrt_a-sprintf_s.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@secapi/$(DEPDIR)/lib64_libmsvcrt_a-strerror_s.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@secapi/$(DEPDIR)/lib64_libmsvcrt_a-vsprintf_s.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@secapi/$(DEPDIR)/lib64_libmsvcrt_a-wmemcpy_s.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@stdio/$(DEPDIR)/lib32_libmingwex_a-_Exit.Po@am__quote@ @@ -20383,6 +20393,20 @@ secapi/lib32_libmsvcrt_a-sprintf_s.obj: secapi/sprintf_s.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lib32_libmsvcrt_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o secapi/lib32_libmsvcrt_a-sprintf_s.obj `if test -f 'secapi/sprintf_s.c'; then $(CYGPATH_W) 'secapi/sprintf_s.c'; else $(CYGPATH_W) '$(srcdir)/secapi/sprintf_s.c'; fi` +secapi/lib32_libmsvcrt_a-strerror_s.o: secapi/strerror_s.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lib32_libmsvcrt_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT secapi/lib32_libmsvcrt_a-strerror_s.o -MD -MP -MF secapi/$(DEPDIR)/lib32_libmsvcrt_a-strerror_s.Tpo -c -o secapi/lib32_libmsvcrt_a-strerror_s.o `test -f 'secapi/strerror_s.c' || echo '$(srcdir)/'`secapi/strerror_s.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) secapi/$(DEPDIR)/lib32_libmsvcrt_a-strerror_s.Tpo secapi/$(DEPDIR)/lib32_libmsvcrt_a-strerror_s.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='secapi/strerror_s.c' object='secapi/lib32_libmsvcrt_a-strerror_s.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lib32_libmsvcrt_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o secapi/lib32_libmsvcrt_a-strerror_s.o `test -f 'secapi/strerror_s.c' || echo '$(srcdir)/'`secapi/strerror_s.c + +secapi/lib32_libmsvcrt_a-strerror_s.obj: secapi/strerror_s.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lib32_libmsvcrt_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT secapi/lib32_libmsvcrt_a-strerror_s.obj -MD -MP -MF secapi/$(DEPDIR)/lib32_libmsvcrt_a-strerror_s.Tpo -c -o secapi/lib32_libmsvcrt_a-strerror_s.obj `if test -f 'secapi/strerror_s.c'; then $(CYGPATH_W) 'secapi/strerror_s.c'; else $(CYGPATH_W) '$(srcdir)/secapi/strerror_s.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) secapi/$(DEPDIR)/lib32_libmsvcrt_a-strerror_s.Tpo secapi/$(DEPDIR)/lib32_libmsvcrt_a-strerror_s.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='secapi/strerror_s.c' object='secapi/lib32_libmsvcrt_a-strerror_s.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lib32_libmsvcrt_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o secapi/lib32_libmsvcrt_a-strerror_s.obj `if test -f 'secapi/strerror_s.c'; then $(CYGPATH_W) 'secapi/strerror_s.c'; else $(CYGPATH_W) '$(srcdir)/secapi/strerror_s.c'; fi` + secapi/lib32_libmsvcrt_a-vsprintf_s.o: secapi/vsprintf_s.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lib32_libmsvcrt_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT secapi/lib32_libmsvcrt_a-vsprintf_s.o -MD -MP -MF secapi/$(DEPDIR)/lib32_libmsvcrt_a-vsprintf_s.Tpo -c -o secapi/lib32_libmsvcrt_a-vsprintf_s.o `test -f 'secapi/vsprintf_s.c' || echo '$(srcdir)/'`secapi/vsprintf_s.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) secapi/$(DEPDIR)/lib32_libmsvcrt_a-vsprintf_s.Tpo secapi/$(DEPDIR)/lib32_libmsvcrt_a-vsprintf_s.Po @@ -29469,6 +29493,20 @@ secapi/lib64_libmsvcrt_a-sprintf_s.obj: secapi/sprintf_s.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lib64_libmsvcrt_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o secapi/lib64_libmsvcrt_a-sprintf_s.obj `if test -f 'secapi/sprintf_s.c'; then $(CYGPATH_W) 'secapi/sprintf_s.c'; else $(CYGPATH_W) '$(srcdir)/secapi/sprintf_s.c'; fi` +secapi/lib64_libmsvcrt_a-strerror_s.o: secapi/strerror_s.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lib64_libmsvcrt_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT secapi/lib64_libmsvcrt_a-strerror_s.o -MD -MP -MF secapi/$(DEPDIR)/lib64_libmsvcrt_a-strerror_s.Tpo -c -o secapi/lib64_libmsvcrt_a-strerror_s.o `test -f 'secapi/strerror_s.c' || echo '$(srcdir)/'`secapi/strerror_s.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) secapi/$(DEPDIR)/lib64_libmsvcrt_a-strerror_s.Tpo secapi/$(DEPDIR)/lib64_libmsvcrt_a-strerror_s.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='secapi/strerror_s.c' object='secapi/lib64_libmsvcrt_a-strerror_s.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lib64_libmsvcrt_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o secapi/lib64_libmsvcrt_a-strerror_s.o `test -f 'secapi/strerror_s.c' || echo '$(srcdir)/'`secapi/strerror_s.c + +secapi/lib64_libmsvcrt_a-strerror_s.obj: secapi/strerror_s.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lib64_libmsvcrt_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT secapi/lib64_libmsvcrt_a-strerror_s.obj -MD -MP -MF secapi/$(DEPDIR)/lib64_libmsvcrt_a-strerror_s.Tpo -c -o secapi/lib64_libmsvcrt_a-strerror_s.obj `if test -f 'secapi/strerror_s.c'; then $(CYGPATH_W) 'secapi/strerror_s.c'; else $(CYGPATH_W) '$(srcdir)/secapi/strerror_s.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) secapi/$(DEPDIR)/lib64_libmsvcrt_a-strerror_s.Tpo secapi/$(DEPDIR)/lib64_libmsvcrt_a-strerror_s.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='secapi/strerror_s.c' object='secapi/lib64_libmsvcrt_a-strerror_s.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lib64_libmsvcrt_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o secapi/lib64_libmsvcrt_a-strerror_s.obj `if test -f 'secapi/strerror_s.c'; then $(CYGPATH_W) 'secapi/strerror_s.c'; else $(CYGPATH_W) '$(srcdir)/secapi/strerror_s.c'; fi` + secapi/lib64_libmsvcrt_a-vsprintf_s.o: secapi/vsprintf_s.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lib64_libmsvcrt_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT secapi/lib64_libmsvcrt_a-vsprintf_s.o -MD -MP -MF secapi/$(DEPDIR)/lib64_libmsvcrt_a-vsprintf_s.Tpo -c -o secapi/lib64_libmsvcrt_a-vsprintf_s.o `test -f 'secapi/vsprintf_s.c' || echo '$(srcdir)/'`secapi/vsprintf_s.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) secapi/$(DEPDIR)/lib64_libmsvcrt_a-vsprintf_s.Tpo secapi/$(DEPDIR)/lib64_libmsvcrt_a-vsprintf_s.Po diff --git a/mingw-w64-crt/lib32/msvcrt.def.in b/mingw-w64-crt/lib32/msvcrt.def.in index f32ecaf..f473f45 100644 --- a/mingw-w64-crt/lib32/msvcrt.def.in +++ b/mingw-w64-crt/lib32/msvcrt.def.in @@ -1202,7 +1202,7 @@ scanf_s sscanf_s strcat_s strcpy_s -strerror_s +; strerror_s replaced by emu strncat_s strncpy_s ; strnlen replaced by emu diff --git a/mingw-w64-crt/lib64/msvcrt.def.in b/mingw-w64-crt/lib64/msvcrt.def.in index 7a442ce..f42d1fc 100644 --- a/mingw-w64-crt/lib64/msvcrt.def.in +++ b/mingw-w64-crt/lib64/msvcrt.def.in @@ -1192,7 +1192,7 @@ strcpy strcpy_s strcspn strerror -strerror_s +; strerror_s replaced by emu strftime strlen strncat diff --git a/mingw-w64-crt/secapi/strerror_s.c b/mingw-w64-crt/secapi/strerror_s.c new file mode 100644 index 0000000..714ad9b --- /dev/null +++ b/mingw-w64-crt/secapi/strerror_s.c @@ -0,0 +1,54 @@ +#include <windows.h> +#include <malloc.h> +#include <errno.h> +#include <msvcrt.h> + +char * __cdecl strerror (int); +errno_t __cdecl strerror_s (char *, size_t, int); +int __cdecl sprintf_s (char *, size_t, const char *, ...); +static errno_t __cdecl _int_strerror_s (char *, size_t, int); +static errno_t __cdecl _stub (char *, size_t, int); + +errno_t __cdecl (*__MINGW_IMP_SYMBOL(strerror_s))(char *, size_t, int) = _stub; + +static errno_t __cdecl +_stub (char *buffer, size_t numberOfElements, int errnum) +{ + errno_t __cdecl (*f)(char *, size_t, int) = __MINGW_IMP_SYMBOL(strerror_s); + + if (f == _stub) + { + f = (errno_t __cdecl (*)(char *, size_t, int)) + GetProcAddress (__mingw_get_msvcrt_handle (), "strerror_s"); + if (!f) + f = _int_strerror_s; + __MINGW_IMP_SYMBOL(strerror_s) = f; + } + return (*f)(buffer, numberOfElements, errnum); +} + +errno_t __cdecl +strerror_s (char *buffer, size_t numberOfElements, int errnum) +{ + return _stub (buffer, numberOfElements, errnum); +} + +static errno_t __cdecl +_int_strerror_s (char *buffer, size_t numberOfElements, int errnum) +{ + char *errmsg = strerror(errnum); + + if (!errmsg || !buffer || numberOfElements == 0) + { + errno = EINVAL; + return EINVAL; + } + + if (sprintf_s(buffer, numberOfElements, "%s", errmsg) == -1) + { + errno = EINVAL; + return EINVAL; + } + + return 0; +} -- 1.8.5.3
------------------------------------------------------------------------------
_______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public