From e53f27b9d9df73461308618151fa6e6392aebd85 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Fri, 16 Apr 2010 17:25:23 +0200 Subject: stash away SCM_RIGHTS fd until a getfd command arrives If there is already a fd in s->msgfd before recvmsg it is closed by parts that this patch does not touch. So, only one descriptor can be "leaked" by attaching it to a command other than getfd. Signed-off-by: Paolo Bonzini Signed-off-by: Luiz Capitulino --- qemu-char.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'qemu-char.c') diff --git a/qemu-char.c b/qemu-char.c index 05df971412..ac65a1c806 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -2000,8 +2000,9 @@ static void tcp_chr_process_IAC_bytes(CharDriverState *chr, static int tcp_get_msgfd(CharDriverState *chr) { TCPCharDriver *s = chr->opaque; - - return s->msgfd; + int fd = s->msgfd; + s->msgfd = -1; + return fd; } #ifndef _WIN32 @@ -2089,10 +2090,6 @@ static void tcp_chr_read(void *opaque) tcp_chr_process_IAC_bytes(chr, s, buf, &size); if (size > 0) qemu_chr_read(chr, buf, size); - if (s->msgfd != -1) { - close(s->msgfd); - s->msgfd = -1; - } } } -- cgit v1.2.1