Still missing after this patch: [v]s[n]wprintf() for UCRT and MSVCRT.
--
Regards,
Christian
From 7d04fa1ddd86a0d46ec3222a1e09455e4b8dd85a Mon Sep 17 00:00:00 2001
From: Christian Franke
Date: Sun, 12 Feb 2023 15:24:46 +0100
Subject: [PATCH] headers: _FORTIFY_SOURCE: Add [v]s[n]printf() for UCRT
Signed-off-by: Christian Franke
---
mingw-w64-headers/crt/stdio.h | 59 ++-
1 file changed, 58 insertions(+), 1 deletion(-)
diff --git a/mingw-w64-headers/crt/stdio.h b/mingw-w64-headers/crt/stdio.h
index 5042409a2..6021c9e47 100644
--- a/mingw-w64-headers/crt/stdio.h
+++ b/mingw-w64-headers/crt/stdio.h
@@ -833,10 +833,67 @@ char * tmpnam(char * __dst)
__attribute__((__format__ (__MINGW_PRINTF_FORMAT, 3, 4)))
__MINGW_ATTRIB_NONNULL(3)
int snprintf (char * __restrict__ __stream, size_t __n, const char *
__restrict__ __format, ...);
+
+#if __MINGW_FORTIFY_LEVEL > 0
+
+ int __cdecl __mingw_call_vsprintf (char * __restrict__ __stream, const char
* __restrict__ __format, va_list __local_argv) __MINGW_ASM_CALL(vsprintf);
+ int __cdecl __mingw_call_vsnprintf (char * __restrict__ __stream, size_t
__n, const char * __restrict__ __format, va_list __local_argv)
__MINGW_ASM_CALL(vsnprintf);
+
+ __mingw_bos_extern_ovr
+ __attribute__((__format__ (__MINGW_PRINTF_FORMAT, 2, 0)))
__MINGW_ATTRIB_NONNULL(3)
+ int vsprintf (char * __restrict__ __stream, const char * __restrict__
__format, va_list __local_argv)
+ {
+if (__mingw_bos_known(__stream)) {
+ int __retval = __mingw_call_vsnprintf (__stream, __mingw_bos(__stream,
1), __format, __local_argv);
+ if (__retval >= 0)
+__mingw_bos_ptr_chk(__stream, (size_t)__retval + 1, 1);
+ return __retval;
+}
+return __mingw_call_vsprintf(__stream, __format, __local_argv);
+ }
+
+ __mingw_bos_extern_ovr
+ __attribute__((__format__ (__MINGW_PRINTF_FORMAT, 3, 0)))
__MINGW_ATTRIB_NONNULL(3)
+ int vsnprintf (char * __restrict__ __stream, size_t __n, const char *
__restrict__ __format, va_list __local_argv)
+ {
+__mingw_bos_ptr_chk_warn(__stream, __n, 1);
+return __mingw_call_vsnprintf (__stream, __n, __format, __local_argv);
+ }
+
+#endif /* __MINGW_FORTIFY_LEVEL > 0 */
+
+#ifdef __MINGW_FORTIFY_VA_ARG
+
+ int __cdecl __mingw_call_sprintf (char * __restrict__ __stream, const char *
__restrict__ __Format, ...) __MINGW_ASM_CALL(sprintf);
+ int __cdecl __mingw_call_snprintf (char * __restrict__ __stream, size_t __n,
const char * __restrict__ __format, ...) __MINGW_ASM_CALL(snprintf);
+
+ __mingw_bos_extern_ovr
+ __attribute__((__format__ (__MINGW_PRINTF_FORMAT, 2, 3)))
__MINGW_ATTRIB_NONNULL(2)
+ int sprintf (char * __restrict__ __stream, const char * __restrict__
__format, ...)
+ {
+if (__mingw_bos_known(__stream)) {
+ int __retval = __mingw_call_snprintf (__stream, __mingw_bos(__stream,
1), __format, __builtin_va_arg_pack());
+ if (__retval >= 0)
+__mingw_bos_ptr_chk(__stream, (size_t)__retval + 1, 1);
+ return __retval;
+}
+return __mingw_call_sprintf (__stream, __format, __builtin_va_arg_pack());
+ }
+
+ __mingw_bos_extern_ovr
+ __attribute__((__format__ (__MINGW_PRINTF_FORMAT, 3, 4)))
__MINGW_ATTRIB_NONNULL(3)
+ int snprintf (char * __restrict__ __stream, size_t __n, const char *
__restrict__ __format, ...)
+ {
+__mingw_bos_ptr_chk_warn(__stream, __n, 1);
+return __mingw_call_snprintf (__stream, __n, __format,
__builtin_va_arg_pack());
+ }
+
+#endif /* __MINGW_FORTIFY_VA_ARG */
+
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
-#else
+#else /* !_UCRT */
/* this is here to deal with software defining
* vsnprintf as _vsnprintf, eg. libxml2. */
--
2.38.1
___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public