> From: Paul Smith <psm...@gnu.org> > Date: Sat, 18 Jun 2022 17:05:44 -0400 > > On Wed, 2022-05-11 at 08:00 +0200, Gisle Vanem wrote: > > The crash and wild call-stack seems to be caused > > by an overflow to 'sprintf(sh_path, ..)'. But replacing > > with 'snprintf()' works w/o any crash: > > I applied changes based on this: some didn't need sprintf() at all; the > rest I used snprintf(). > > I do have a memory that some versions of Visual Studio, up until > relatively recently, have non-standard implementations of snprintf() > but hopefully it's standard enough to manage this.
If we now rely on ANSI-standard behavior of snprintf in the Windows port, we need the MinGW build to use -D__USE_MINGW_ANSI_STDIO=1, to force replacement of the MS version of snprintf with MinGW's own reimplementation, which is ANSI-standard. That's because linking Make against MSVCRT.DLL will use a non-compliant snprintf in that DLL (MinGW cannot link against proprietary C runtime libraries that come with later versions of Visual Studio).