Package: mingw32
Version: 4.2.1.dfsg-1

Hi Ron,

See Werner's e-mail below.  I believe it is possible to reproduce the
problem using this small code snippet:

j...@mocca:~$ cat>foo.c
#include <stdio.h>
int main (void)
{
  char buf[1024];
  int c = 65;
  long d = 18;
  int f = 42;
  snprintf (buf, 1024, "foo %d bar %ld bee %d", c, d, f);
  puts (buf);
}
j...@mocca:~$ gcc -o foo foo.c;./foo
foo 65 bar 18 bee 42
j...@mocca:~$ i586-mingw32msvc-gcc -o foo.exe foo.c;wine ./foo.exe 
foo 65 bar 180388626450 bee 6422184
j...@mocca:~$ 

If my example is correct, this seems like a pretty severe bug to me
which may cause data corruption in programs built with this compiler.
Possibly the severity should be higher.

Thanks,
/Simon

Werner Koch <[email protected]> writes:

> On Fri, 18 Dec 2009 07:20:36 +0100, Simon Josefsson wrote:
>> 
>> "Hoyt, David" <[email protected]> writes:
>> 
>> >> If you want a makefile that does everything, check out
>> >> <http://*josefsson.org/gnutls4win/Makefile>.
>> >
>> > What version of gcc do you use (in the mingw toolchain)?
>> 
>> I'm using the 'mingw32' package from debian, which appears to be gcc 4.2
>> based.  http://packages.qa.debian.org/m/mingw32.html
>
> Take care:  The mingw packages in Debian are broken:
>
>   as GNU make.  We are using Debian GNU/Linux (Lenny); due to a little
>   bug in the mingw32 compiler it is highly suggested to put a line
>     deb http://apt.intevation.org lenny/mingw .
>   into /etc/apt/sources and update the mingw packages.
>
> they replaced the snprintf and introduced a bug.  IIRC, "%lu" requires
> an "unsigned long long" arg and not an "unsigned long".  The result is
> that the stack is messed up and you get all kinds of strange error.
> At one point it took us many hours of debugging until we realized that
> some parts of a system were build with the broken mingw runtime.  The
> fix is trivial but still hasn't made it into Debian.
>
> I think libgcrypt does not use printf with "%lu" but that may depend
> on the version.
>
>
> Shalom-Salam,
>
>    Werner



-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to