Hey,

Here's a patch which implements a secapi wrapper for the sprintf_s
symbol. It's needed to fix Windows XP compatibility in Qt5/ANGLE as
mentioned at https://bugzilla.redhat.com/show_bug.cgi?id=1057983

Okay to apply?

Regards,

Erik
>From dca6ecb46f9b3f2d5652bf27208ac4ecdae1a652 Mon Sep 17 00:00:00 2001
From: Erik van Pienbroek <epien...@fedoraproject.org>
Date: Sun, 26 Jan 2014 20:15:44 +0100
Subject: [PATCH] Add secapi wrapper for sprintf_s

---
 mingw-w64-crt/Makefile.am         |  1 +
 mingw-w64-crt/Makefile.in         | 45 +++++++++++++++++++++++++++++++++++----
 mingw-w64-crt/lib32/msvcrt.def.in |  2 +-
 mingw-w64-crt/lib64/msvcrt.def.in |  2 +-
 mingw-w64-crt/secapi/sprintf_s.c  | 21 ++++++++++++++++++
 5 files changed, 65 insertions(+), 6 deletions(-)
 create mode 100644 mingw-w64-crt/secapi/sprintf_s.c

diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am
index ea384ac..bdca4fa 100644
--- a/mingw-w64-crt/Makefile.am
+++ b/mingw-w64-crt/Makefile.am
@@ -180,6 +180,7 @@ src_msvcrt=\
   secapi/asctime_s.c \
   secapi/memcpy_s.c \
   secapi/rand_s.c \
+  secapi/sprintf_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 6669467..4c0c1cb 100644
--- a/mingw-w64-crt/Makefile.in
+++ b/mingw-w64-crt/Makefile.in
@@ -1114,8 +1114,8 @@ 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/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/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) \
@@ -1151,6 +1151,7 @@ am__objects_20 =  \
 	secapi/lib32_libmsvcrt_a-asctime_s.$(OBJEXT) \
 	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-vsprintf_s.$(OBJEXT) \
 	secapi/lib32_libmsvcrt_a-wmemcpy_s.$(OBJEXT)
 am__objects_21 = $(am__objects_20) \
@@ -2246,8 +2247,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/vsprintf_s.c secapi/wmemcpy_s.c \
-	lib64/msvcrt.def.in
+	secapi/rand_s.c secapi/sprintf_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) \
@@ -2283,6 +2284,7 @@ am__objects_52 =  \
 	secapi/lib64_libmsvcrt_a-asctime_s.$(OBJEXT) \
 	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-vsprintf_s.$(OBJEXT) \
 	secapi/lib64_libmsvcrt_a-wmemcpy_s.$(OBJEXT)
 @LIB64_TRUE@@W32API_FALSE@am_lib64_libmsvcrt_a_OBJECTS =  \
@@ -3905,6 +3907,7 @@ src_msvcrt = \
   secapi/asctime_s.c \
   secapi/memcpy_s.c \
   secapi/rand_s.c \
+  secapi/sprintf_s.c \
   secapi/vsprintf_s.c \
   secapi/wmemcpy_s.c
 
@@ -7039,6 +7042,8 @@ secapi/lib32_libmsvcrt_a-memcpy_s.$(OBJEXT): secapi/$(am__dirstamp) \
 	secapi/$(DEPDIR)/$(am__dirstamp)
 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-vsprintf_s.$(OBJEXT): secapi/$(am__dirstamp) \
 	secapi/$(DEPDIR)/$(am__dirstamp)
 secapi/lib32_libmsvcrt_a-wmemcpy_s.$(OBJEXT): secapi/$(am__dirstamp) \
@@ -8635,6 +8640,8 @@ secapi/lib64_libmsvcrt_a-memcpy_s.$(OBJEXT): secapi/$(am__dirstamp) \
 	secapi/$(DEPDIR)/$(am__dirstamp)
 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-vsprintf_s.$(OBJEXT): secapi/$(am__dirstamp) \
 	secapi/$(DEPDIR)/$(am__dirstamp)
 secapi/lib64_libmsvcrt_a-wmemcpy_s.$(OBJEXT): secapi/$(am__dirstamp) \
@@ -11012,6 +11019,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@secapi/$(DEPDIR)/lib32_libmsvcrt_a-asctime_s.Po@am__quote@
 @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-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@
@@ -11046,6 +11054,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@secapi/$(DEPDIR)/lib64_libmsvcrt_a-asctime_s.Po@am__quote@
 @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-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@
@@ -20360,6 +20369,20 @@ secapi/lib32_libmsvcrt_a-rand_s.obj: secapi/rand_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-rand_s.obj `if test -f 'secapi/rand_s.c'; then $(CYGPATH_W) 'secapi/rand_s.c'; else $(CYGPATH_W) '$(srcdir)/secapi/rand_s.c'; fi`
 
+secapi/lib32_libmsvcrt_a-sprintf_s.o: secapi/sprintf_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-sprintf_s.o -MD -MP -MF secapi/$(DEPDIR)/lib32_libmsvcrt_a-sprintf_s.Tpo -c -o secapi/lib32_libmsvcrt_a-sprintf_s.o `test -f 'secapi/sprintf_s.c' || echo '$(srcdir)/'`secapi/sprintf_s.c
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) secapi/$(DEPDIR)/lib32_libmsvcrt_a-sprintf_s.Tpo secapi/$(DEPDIR)/lib32_libmsvcrt_a-sprintf_s.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='secapi/sprintf_s.c' object='secapi/lib32_libmsvcrt_a-sprintf_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-sprintf_s.o `test -f 'secapi/sprintf_s.c' || echo '$(srcdir)/'`secapi/sprintf_s.c
+
+secapi/lib32_libmsvcrt_a-sprintf_s.obj: secapi/sprintf_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-sprintf_s.obj -MD -MP -MF secapi/$(DEPDIR)/lib32_libmsvcrt_a-sprintf_s.Tpo -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`
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) secapi/$(DEPDIR)/lib32_libmsvcrt_a-sprintf_s.Tpo secapi/$(DEPDIR)/lib32_libmsvcrt_a-sprintf_s.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='secapi/sprintf_s.c' object='secapi/lib32_libmsvcrt_a-sprintf_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-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-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
@@ -29432,6 +29455,20 @@ secapi/lib64_libmsvcrt_a-rand_s.obj: secapi/rand_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-rand_s.obj `if test -f 'secapi/rand_s.c'; then $(CYGPATH_W) 'secapi/rand_s.c'; else $(CYGPATH_W) '$(srcdir)/secapi/rand_s.c'; fi`
 
+secapi/lib64_libmsvcrt_a-sprintf_s.o: secapi/sprintf_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-sprintf_s.o -MD -MP -MF secapi/$(DEPDIR)/lib64_libmsvcrt_a-sprintf_s.Tpo -c -o secapi/lib64_libmsvcrt_a-sprintf_s.o `test -f 'secapi/sprintf_s.c' || echo '$(srcdir)/'`secapi/sprintf_s.c
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) secapi/$(DEPDIR)/lib64_libmsvcrt_a-sprintf_s.Tpo secapi/$(DEPDIR)/lib64_libmsvcrt_a-sprintf_s.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='secapi/sprintf_s.c' object='secapi/lib64_libmsvcrt_a-sprintf_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-sprintf_s.o `test -f 'secapi/sprintf_s.c' || echo '$(srcdir)/'`secapi/sprintf_s.c
+
+secapi/lib64_libmsvcrt_a-sprintf_s.obj: secapi/sprintf_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-sprintf_s.obj -MD -MP -MF secapi/$(DEPDIR)/lib64_libmsvcrt_a-sprintf_s.Tpo -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`
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) secapi/$(DEPDIR)/lib64_libmsvcrt_a-sprintf_s.Tpo secapi/$(DEPDIR)/lib64_libmsvcrt_a-sprintf_s.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='secapi/sprintf_s.c' object='secapi/lib64_libmsvcrt_a-sprintf_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-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-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 3455447..f32ecaf 100644
--- a/mingw-w64-crt/lib32/msvcrt.def.in
+++ b/mingw-w64-crt/lib32/msvcrt.def.in
@@ -1198,7 +1198,7 @@ memmove_s
 printf_s
 qsort_s
 scanf_s
-sprintf_s
+; sprintf_s replaced by emu
 sscanf_s
 strcat_s
 strcpy_s
diff --git a/mingw-w64-crt/lib64/msvcrt.def.in b/mingw-w64-crt/lib64/msvcrt.def.in
index ceff01e..7a442ce 100644
--- a/mingw-w64-crt/lib64/msvcrt.def.in
+++ b/mingw-w64-crt/lib64/msvcrt.def.in
@@ -1177,7 +1177,7 @@ sin
 sinh
 ;sinhf
 sprintf
-sprintf_s
+; sprintf_s replaced by emu
 sqrt DATA
 sqrtf DATA
 srand
diff --git a/mingw-w64-crt/secapi/sprintf_s.c b/mingw-w64-crt/secapi/sprintf_s.c
new file mode 100644
index 0000000..8c60797
--- /dev/null
+++ b/mingw-w64-crt/secapi/sprintf_s.c
@@ -0,0 +1,21 @@
+#include <windows.h>
+#include <malloc.h>
+#include <errno.h>
+#include <msvcrt.h>
+
+int __cdecl sprintf_s (char *, size_t, const char *, ...);
+int __cdecl vsprintf_s (char *, size_t, const char *, va_list);
+
+int __cdecl (*__MINGW_IMP_SYMBOL(sprintf_s))(char *, size_t, const char *,...) = sprintf_s;
+
+int __cdecl
+sprintf_s (char *_DstBuf, size_t _Size, const char *_Format, ...)
+{
+  va_list argp;
+  int r;
+
+  va_start (argp, _Format);
+  r = vsprintf_s (_DstBuf, _Size, _Format, argp);
+  va_end (argp);
+  return r; 
+}
-- 
1.8.5.3

------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today.
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to