http://bugs.winehq.org/show_bug.cgi?id=14192
Anastasius Focht focht@gmx.net changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |focht@gmx.net
--- Comment #3 from Anastasius Focht focht@gmx.net 2008-06-30 05:22:04 --- Hello,
the program uses C++ iostreams to write binary chunks into files. The stream i/o implementation use underlying C runtime file API (msvcrt) for carrying out the file operations.
--- snip --- 0009:Call msvcrt.fopen(0400c959 "C:\windows\profiles\focht\ElsterFormular\2007-2008\2AdxAAYeCi8t\2007CS0000.cert",76077374 "wb") ret=76042aa6 0009:Call KERNEL32.CreateFileA(0400c959 "C:\windows\profiles\rmi\ElsterFormular\2007-2008\2AdxAAYeCi8t\2007CS0000.cert",40000000,00000003,0188ef20,00000002,00000080,00000000) ret=60f4e2da 0009:Ret KERNEL32.CreateFileA() retval=000000f8 ret=60f4e2da 0009:Ret msvcrt.fopen() retval=001a71f0 ret=76042aa6 .. 0009:Call KERNEL32.WriteFile(000000f8,0019dce0,0000004e,0188eee8,00000000) ret=60f500a5 0009:Ret KERNEL32.WriteFile() retval=00000001 ret=60f500a5 0009:Ret msvcrt.fputc() retval=0000000a ret=76024e3e 0009:Call msvcrt.fputc(00000032,001a71f0) ret=76024e3e 0009:Ret msvcrt.fputc() retval=00000032 ret=76024e3e 0009:Call msvcrt.fputc(00000030,001a71f0) ret=76024e3e .. 0009:Call msvcrt.fputc(ffffffff,001a71f0) ret=76024e3e 0009:Ret msvcrt.fputc() retval=ffffffff ret=76024e3e 0009:Call ntdll.strlen(760775e0 "ios::badbit set") ret=76021f99 0009:Ret ntdll.strlen() retval=0000000f ret=76021f99 0009:Call msvcrt.??2@YAPAXI@Z(00000021) ret=760226a2 .. 0009:Call msvcrt._CxxThrowException(0188efbc,7607d79c) ret=76023134 0009:Call KERNEL32.RaiseException(e06d7363,00000001,00000003,0188ef1c) ret=60f44a6c 0009:trace:seh:raise_exception code=e06d7363 flags=1 addr=0x7b8432c0 0009:trace:seh:raise_exception info[0]=19930520 0009:trace:seh:raise_exception info[1]=0188efbc 0009:trace:seh:raise_exception info[2]=7607d79c 0009:trace:seh:raise_exception eax=7b82c449 ebx=7b8b2880 ecx=00000000 edx=0188ef1c esi=0188ef1c edi=0188ee90 0009:trace:seh:raise_exception ebp=0188ee78 esp=0188ee14 cs=0073 ds=007b es=007b fs=0033 gs=003b flags=00000246 --- snip ---
The "character" argument (int) is sign extended before getting passed into fputc(), hence the 0xffffffff value. Wine's fputc() returns the character written as passed in on some code paths, which results in (int) -1 returned. This value is interpreted by upper layer streams impl as EOF -> failure. Solution: cast to unsigned char range/zero extend upon return.
The patch submitter should add small conformance test for this issue.
--- snip --- diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c index f85afd3..c26a400 100644 --- a/dlls/msvcrt/file.c +++ b/dlls/msvcrt/file.c @@ -2539,7 +2539,7 @@ int CDECL MSVCRT_fputc(int c, MSVCRT_FILE* file) return res ? res : c; } else - return c; + return (unsigned char)c; } else { return MSVCRT__flsbuf(c, file); } @@ -2568,7 +2568,7 @@ int CDECL MSVCRT__flsbuf(int c, MSVCRT_FILE* file) unsigned char cc=c; int len; len = MSVCRT__write(file->_file, &cc, 1); - if (len == 1) return c; + if (len == 1) return (unsigned char)c; file->_flag |= MSVCRT__IOERR; return MSVCRT_EOF; } --- snip ---
With that patch applied, the "plausibility check" succeeds.
Regards