http://bugs.winehq.org/show_bug.cgi?id=21289
Summary: System call "dup2" returns 0 for negative inputs, thus behaving different from real Windows Product: Wine Version: 1.0.1 Platform: x86 OS/Version: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: -unknown AssignedTo: wine-bugs@winehq.org ReportedBy: simon@josefsson.org
The program below when run under Wine will print:
rc 0
When I run the same binary on Windows XP, I get:
rc -1
The problem appears to be that the "dup2" system function doesn't do proper input checking.
This is causing self-tests errors for projects (including several GNU projects) that use some gnulib modules.
/Simon
jas@mocca:~$ cat foo.c #include <unistd.h> #include <stdio.h> #include <errno.h> #include <fcntl.h>
/* Get declarations of the Win32 API functions. */ # define WIN32_LEAN_AND_MEAN # include <windows.h>
int main (void) { const char *file = "test-dup2.tmp"; char buffer[1]; int fd = open (file, O_CREAT | O_TRUNC | O_RDWR, 0600); int rc;
rc = dup2 (fd, -2); printf ("rc %d\n", rc);
return 0; } jas@mocca:~$ i586-mingw32msvc-gcc -o foo.exe foo.c jas@mocca:~$ wine ./foo.exe rc 0 jas@mocca:~$ wine --version wine-1.0.1 jas@mocca:~$