[Bug 37940] New: Invalid file buffering behavior causes data corruption
wine-bugs at winehq.org
wine-bugs at winehq.org
Wed Jan 21 01:51:36 CST 2015
https://bugs.winehq.org/show_bug.cgi?id=37940
Bug ID: 37940
Summary: Invalid file buffering behavior causes data corruption
Product: Wine
Version: 1.7.34
Hardware: x86
OS: Linux
Status: UNCONFIRMED
Severity: major
Priority: P2
Component: msvcrt
Assignee: wine-bugs at winehq.org
Reporter: ho-rr-or at mail.ru
Distribution: ---
Created attachment 50543
--> https://bugs.winehq.org/attachment.cgi?id=50543
Compiled binary to reproduce
msvcrt file routines sometimes corrupt file data by invalid buffer flushing.
Reproduced by following code (compiled binary attached):
char data[68200];
char buf[sizeof(data)];
for (int i = 0; i < sizeof(data); i++)
data[i] = rand();
FILE* f = _wfsopen(L"test.bin", L"wb+", 64);
rewind(f);
fwrite(data, 1, 68100, f);
// Following calls possible corrupt buffer
rewind(f);
fread(buf, 1, 40000, f);
fread(buf, 1, 40000, f);
// Following call causes wrong buffer flushing
fwrite(&data[68100], 1, 100, f);
fclose(f);
f = fopen("test.bin", "rb");
fread(buf, 1, sizeof(buf), f);
fclose(f);
printf("Memcmp: %d\n", memcmp(data, buf, sizeof(buf)));
Windows output:
Memcmp: 0
Wine output:
Memcmp: -1
Windows file size: 68200
Wine file size: 72296
Bug causes at least cl.exe in Microsoft Visual Studio 2008/2010. Reproduced
when cl.exe generates precompiled header.
test.h:
#pragma once
#include "Windows.h"
#include <iostream>
test.cpp:
#include "test.h"
int main()
{
std::cout << "WORKS!" << std::endl;
return 0;
}
Command to reproduce:
rm test.pch; wine cl.exe /Yctest.h test.cpp
--
Do not reply to this email, post in Bugzilla using the
above URL to reply.
You are receiving this mail because:
You are watching all bug changes.
More information about the wine-bugs
mailing list