-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

mingw-w64 ANSI printf has these checks, so why not MS printf?

patch is attached

P.S. This is an old patch that's been sitting in my toolchain for a year. I
don't remember why i've added it, but it seems to not to break anything.

- -- 
O< ascii ribbon - stop html email! - www.asciiribbon.org

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQEcBAEBCAAGBQJXGl4FAAoJEOs4Jb6SI2Cws4YH/26ATu+vL6TLHmfD43cgeUcX
lfQkAx7gCRYJfGh7rgSlGXKkQfEamCXadH4/OAizTzVLJNf7XYASpPzCtSNunUw4
C+GOWCsD6Rho5nduuoW6nd+JB8ZCky8cVYGKbKfQZZnzAJwIoi1uIzqaSWoWqk0Y
9wbW8uigjolsdVWc+sBMqQuPHXbdLTxWA2mUIA64I+/cUN5m/Dwui6qfLiYSW4zr
iA3U7eUk/xvUSOdEPKfanPF0uiq+rVzprgiQDlkk2BZUGtX7Zin3ps78M7dKrZL9
UYmuqoirjmLZsf/SstTM3IQqSm51OcTq8yl2H548LwOAV2fDpCdbFTh90PLuYxM=
=x1tk
-----END PGP SIGNATURE-----
From 05c30154fe5762c4303414e6387a0a301208b9c3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D0=BB=D0=B0=D0=BD=20=D0=98=D0=B6=D0=B1?=
 =?UTF-8?q?=D1=83=D0=BB=D0=B0=D1=82=D0=BE=D0=B2?= <lrn1...@gmail.com>
Date: Fri, 22 Apr 2016 05:29:22 +0000
Subject: [PATCH] Check for ms_printf format and non-NULL format in MS printf
 funcs.

mingw-w64 ANSI printf has these checks, so why not MS printf?
---
 mingw-w64-headers/crt/stdio.h | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/mingw-w64-headers/crt/stdio.h b/mingw-w64-headers/crt/stdio.h
index 3b49ddd..9f1cfff 100644
--- a/mingw-w64-headers/crt/stdio.h
+++ b/mingw-w64-headers/crt/stdio.h
@@ -374,41 +374,53 @@ int vsnprintf (char *__stream, size_t __n, const char 
*__format, __builtin_va_li
 /*
  * Default configuration: simply direct all calls to MSVCRT...
  */
+  __attribute__((__format__ (ms_printf, 2, 3))) __MINGW_ATTRIB_NONNULL(2)
   int __cdecl fprintf(FILE * __restrict__ _File,const char * __restrict__ 
_Format,...);
+  __attribute__((__format__ (ms_printf, 1, 2))) __MINGW_ATTRIB_NONNULL(1)
   int __cdecl printf(const char * __restrict__ _Format,...);
+  __attribute__((__format__ (ms_printf, 2, 3))) __MINGW_ATTRIB_NONNULL(2)
   int __cdecl sprintf(char * __restrict__ _Dest,const char * __restrict__ 
_Format,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
 
+  __attribute__((__format__ (ms_printf, 2, 0))) __MINGW_ATTRIB_NONNULL(2)
   int __cdecl vfprintf(FILE * __restrict__ _File,const char * __restrict__ 
_Format,va_list _ArgList);
+  __attribute__((__format__ (ms_printf, 1, 0))) __MINGW_ATTRIB_NONNULL(1)
   int __cdecl vprintf(const char * __restrict__ _Format,va_list _ArgList);
+  __attribute__((__format__ (ms_printf, 2, 0))) __MINGW_ATTRIB_NONNULL(2)
   int __cdecl vsprintf(char * __restrict__ _Dest,const char * __restrict__ 
_Format,va_list _Args) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
 
+  __attribute__((__format__ (ms_scanf, 2, 3))) __MINGW_ATTRIB_NONNULL(2)
   int __cdecl fscanf(FILE * __restrict__ _File,const char * __restrict__ 
_Format,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
+  __attribute__((__format__ (ms_scanf, 1, 2))) __MINGW_ATTRIB_NONNULL(1)
   int __cdecl scanf(const char * __restrict__ _Format,...) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
+  __attribute__((__format__ (ms_scanf, 2, 3))) __MINGW_ATTRIB_NONNULL(2)
   int __cdecl sscanf(const char * __restrict__ _Src,const char * __restrict__ 
_Format,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
 #ifdef _GNU_SOURCE
   int __cdecl vasprintf(char ** __restrict__ ret,const char * __restrict__ 
format,va_list ap)  __attribute__ ((format (__MINGW_PRINTF_FORMAT, 2, 0)));;
   int __cdecl asprintf(char ** __restrict__ ret,const char * __restrict__ 
format,...) __attribute__ ((format (__MINGW_PRINTF_FORMAT, 2, 3)));
 #endif /*_GNU_SOURCE*/
 #ifndef __NO_ISOCEXT  /* externs in libmingwex.a */
+  __attribute__((__format__ (ms_scanf, 1, 0))) __MINGW_ATTRIB_NONNULL(1)
   int __cdecl __ms_vscanf(const char * __restrict__ Format, va_list argp);
+  __attribute__((__format__ (ms_scanf, 2, 0))) __MINGW_ATTRIB_NONNULL(2)
   int __cdecl __ms_vfscanf (FILE * __restrict__ fp, const char * __restrict__ 
Format,va_list argp);
+  __attribute__((__format__ (ms_scanf, 2, 0))) __MINGW_ATTRIB_NONNULL(2)
   int __cdecl __ms_vsscanf (const char * __restrict__ _Str,const char * 
__restrict__ Format,va_list argp);
 
   __mingw_ovr
-  __MINGW_ATTRIB_NONNULL(2)
+  __attribute__((__format__ (ms_scanf, 2, 0))) __MINGW_ATTRIB_NONNULL(2)
   int vfscanf (FILE *__stream,  const char *__format, __builtin_va_list 
__local_argv)
   {
     return __ms_vfscanf (__stream, __format, __local_argv);
   }
 
   __mingw_ovr
-  __MINGW_ATTRIB_NONNULL(2)
+  __attribute__((__format__ (ms_scanf, 2, 0))) __MINGW_ATTRIB_NONNULL(2)
   int vsscanf (const char * __restrict__ __source, const char * __restrict__ 
__format, __builtin_va_list __local_argv)
   {
     return __ms_vsscanf( __source, __format, __local_argv );
   }
   __mingw_ovr
-  __MINGW_ATTRIB_NONNULL(1)
+  __attribute__((__format__ (ms_scanf, 1, 0))) __MINGW_ATTRIB_NONNULL(1)
   int vscanf(const char *__format,  __builtin_va_list __local_argv)
   {
     return __ms_vscanf (__format, __local_argv);
@@ -525,7 +537,9 @@ int vsnprintf (char *__stream, size_t __n, const char 
*__format, __builtin_va_li
   char *__cdecl tmpnam(char *_Buffer);
   int __cdecl ungetc(int _Ch,FILE *_File);
 
+  __attribute__((__format__ (ms_printf, 3, 4))) __MINGW_ATTRIB_NONNULL(3)
   _CRTIMP int __cdecl _snprintf(char * __restrict__ _Dest,size_t _Count,const 
char * __restrict__ _Format,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
+  __attribute__((__format__ (ms_printf, 3, 0))) __MINGW_ATTRIB_NONNULL(3)
   _CRTIMP int __cdecl _vsnprintf(char * __restrict__ _Dest,size_t _Count,const 
char * __restrict__ _Format,va_list _Args) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
 
 #if !defined (__USE_MINGW_ANSI_STDIO) || __USE_MINGW_ANSI_STDIO == 0
@@ -535,21 +549,23 @@ int vsnprintf (char *__stream, size_t __n, const char 
*__format, __builtin_va_li
 #pragma push_macro("vsnprintf")
 # undef snprintf
 # undef vsnprintf
+  __attribute__((__format__ (ms_printf, 3, 0))) __MINGW_ATTRIB_NONNULL(3)
   int __cdecl __ms_vsnprintf(char * __restrict__ d,size_t n,const char * 
__restrict__ format,va_list arg)
     __MINGW_ATTRIB_DEPRECATED_MSVC2005 __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
 
   __mingw_ovr
-  __MINGW_ATTRIB_NONNULL(3)
+  __attribute__((__format__ (ms_printf, 3, 0))) __MINGW_ATTRIB_NONNULL(3)
   int vsnprintf (char * __restrict__ __stream, size_t __n, const char * 
__restrict__ __format, va_list __local_argv)
   {
     return __ms_vsnprintf (__stream, __n, __format, __local_argv);
   }
 
+  __attribute__((__format__ (ms_printf, 3, 4))) __MINGW_ATTRIB_NONNULL(3)
   int __cdecl __ms_snprintf(char * __restrict__ s, size_t n, const char * 
__restrict__  format, ...);
 
 #ifndef __NO_ISOCEXT
 __mingw_ovr
-__MINGW_ATTRIB_NONNULL(3)
+__attribute__((__format__ (ms_printf, 3, 4))) __MINGW_ATTRIB_NONNULL(3)
 int snprintf (char * __restrict__ __stream, size_t __n, const char * 
__restrict__ __format, ...)
 {
   register int __retval;
-- 
2.4.0

------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to