[Bug 21289] New: System call "dup2" returns 0 for negative inputs, thus behaving different from real Windows

wine-bugs at winehq.org wine-bugs at winehq.org
Fri Jan 8 16:24:50 CST 2010


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 at winehq.org
        ReportedBy: simon at 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 at 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 at mocca:~$ i586-mingw32msvc-gcc -o foo.exe foo.c
jas at mocca:~$ wine ./foo.exe
rc 0
jas at mocca:~$ wine --version
wine-1.0.1
jas at mocca:~$

-- 
Configure bugmail: http://bugs.winehq.org/userprefs.cgi?tab=email
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