]> 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)
committerDaniel P. Berrange <berrange@redhat.com>
Fri, 3 May 2013 13:06:15 +0000 (14:06 +0100)
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>
src/rpc/virnetsocket.c

index e950d7fd77f56973baab9766dcdfc2a6b5280c58..dcf98b1e933c18f2673c83a6ca0fbea05c24d223 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) {