]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Fix F_DUPFD_CLOEXEC operation args
authorDaniel P. Berrange <berrange@redhat.com>
Fri, 3 May 2013 10:10:50 +0000 (11:10 +0100)
committerEric Blake <eblake@redhat.com>
Mon, 6 May 2013 20:16:14 +0000 (14:16 -0600)
The F_DUPFD_CLOEXEC operation with fcntl() expects a single
int argument, specifying the minimum FD number for the newly
dup'd file descriptor. We were not specifying that causing
random stack data to be accessed as the FD number. Sometimes
that worked, sometimes it didn't.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit d6670a64e1067f29da3c3e032739e140280b763d)

src/rpc/virnetsocket.c

index c4fd9ee98157369cd8819d8e3252c8664bdb81b1..14c4a4f907de1c5282a333f9afa1c502cb2a2c72 100644 (file)
@@ -1055,7 +1055,7 @@ int virNetSocketDupFD(virNetSocketPtr sock, bool cloexec)
     int fd;
 
     if (cloexec)
-        fd = fcntl(sock->fd, F_DUPFD_CLOEXEC);
+        fd = fcntl(sock->fd, F_DUPFD_CLOEXEC, 0);
     else
         fd = dup(sock->fd);
     if (fd < 0) {