On Wed, 9 Feb 2022, Pali Rohár wrote:

On Tuesday 08 February 2022 11:25:43 Martin Storsjö wrote:
On Sun, 6 Feb 2022, Pali Rohár wrote:

Currently v*scanf functions are broken and crash when are called with more
than 30 arguments in va_list. This is because va_list v*scanf functions are
redirected to variadic *scanf functions and this redirect implemented in
scanf.S file has fixed limit for 30 arguments.

Number of arguments for msvcrt *scanf function can be determined from
format string by counting number of '%' characters which is the upper
limit. *scanf functions would not access more arguments than this number.
Every scanf parameter is pointer, it has fixed size and so upper stack size
limit can be exactly calculated.

Fix this scanf.S redirect implementation by dynamically allocating stack
for upper limit of pointer parameters.

---

I have tested this patch for i686 and x86_64. Both ARM (arm32 and aarch64)
changes are untested, so please test it if vsscanf() on these platforms
still works.

I wonder if we should try to keep the stack 16 byte aligned for i686 too -
GCC generally tries to keep such alignment on i686 too (even if it isn't
strictly required by the ABI). Then again, the only function we call there
is the msvcrt.dll function, which shouldn't assume anything else than 4 byte
alignment, so maybe it's fine.

I do not have any opinion here. If msvc compiler does not align stack to
16 bytes when doing calls to msvcrt.dll functions then I think it is not
needed.

Ok, I pushed this form (with my fixes) then. 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