On Sun, 6 Mar 2022, Pali Rohár wrote:

crtdll.dll runtime does not suppport 64-bit printf/scanf modifiers. So when
targeting crtdll.dll runtime and not using MinGW-w64 stdio functions then
do not define any 64-bit modifier in inttypes.h header file.

crtdll.dll does not interpret %I64d modifier and does not read next
argument from variadic function call. So usage of this modifier cause
shifting of all variadic arguments.

This change will cause compile errors for crtdll.dll application which are
going to use PRId64 without __USE_MINGW_ANSI_STDIO. Compile error is better
than random runtime crashes or wrong behavior by corruption of printf/scanf
stack.

gcc automatically predefines macro __CRTDLL__ when compiling for crtdll.dll
runtime, so use it in inttypes.h checks.

crtdll.dll based applications which use 64-bit int stdio support had to use
-D__USE_MINGW_ANSI_STDIO=1 compile flag even prior this change.

Non-crtdll.dll based applications (msvcrt.dll or ucrt; which is the
majority) are not affected by this change.

So there there should not be any issue with this change and it should help
to prevent stdio function overflows for crtdll.dll applications.
---
mingw-w64-headers/crt/inttypes.h | 48 +++++++++++++++++++++++++++++++-
1 file changed, 47 insertions(+), 1 deletion(-)

These three patches seemed fine to me, so I pushed them. Thanks!

// Martin

_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to