https://bugs.winehq.org/show_bug.cgi?id=38558
Bug ID: 38558 Summary: cmd.exe bundled with Windows XP messed up when using FOR /F Product: Wine Version: 1.7.42 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: -unknown Assignee: wine-bugs@winehq.org Reporter: katsunori.kumatani@gmail.com Distribution: Mint
I found some pretty old batch scripts I had laying around, so I decided to test if wine could run them fine. I'm using latest version (1.7.42) as of this time, on Linux Mint 17.1 Rebecca, and using the cmd.exe from a Windows XP SP2 old installation media.
cmd has the ability to scan through files (and separating each line into tokens) using the "FOR /F" method. For example, to reproduce this, create a simple text file (test.txt) and put ascending numbers on each line (up to 16 for now):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Then use this command in the cmd.exe:
FOR /F "tokens=*" %A IN (test.txt) DO @echo %A
It SHOULD display all 16 lines in turn, but it's only displaying until 10. If you take out the last two lines (15 and 16), then it will display ONLY until 5, i.e:
1 2 3 4 5
This is a serious bug IF it is within wine because it obviously is something that affects data integrity and not just a glitch.
I am positive that it replaces the last bytes of a file with some junk/overflows or something like that (making it a security issue), which is why it stops "early" since it finds a NULL character, and windows processor stops at a null.
I'm sure of that because AkelPad 4.1.2 has a similar bug: there's non-sensical binary data on every file you open with it! (i.e you open a file and re-save it, and it's messed up at the end in the output...). But the latest version of it, AkelPad 4.2.3, seems to not have this issue, which makes me think if it's really a wine bug or not. I would still appreciate if you had a small look at the file functions (and eof) though.
Note, I couldn't find out how to use wineconsole or wine's built-in cmd at all, it doesn't seem to work at all with FOR /F or at least not in any way properly?
Unfortunately I can't attach a log or something since using the cmd.exe puts it in the shell from where I invoke it... so wine's messages are not visible, unless I am missing something?