Patchwork [02/19] qemu-char: Use qemu_open() to avoid leaking fds to children

login
register
mail settings
Submitter Markus Armbruster
Date Feb. 7, 2012, 2:09 p.m.
Message ID <1328623766-12287-3-git-send-email-armbru@redhat.com>
Download mbox | patch
Permalink /patch/139938/
State New
Headers show

Comments

Markus Armbruster - Feb. 7, 2012, 2:09 p.m.
Fixed silently in commit aad04cd0, but that just got reverted.
Re-apply the fixes, plus one missed instance: parport on Linux.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 qemu-char.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
Anthony Liguori - Feb. 7, 2012, 3:07 p.m.
On 02/07/2012 08:09 AM, Markus Armbruster wrote:
> Fixed silently in commit aad04cd0, but that just got reverted.
> Re-apply the fixes, plus one missed instance: parport on Linux.
>
> Signed-off-by: Markus Armbruster<armbru@redhat.com>

Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>

Regards,

Anthony Liguori

> ---
>   qemu-char.c |    8 ++++----
>   1 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/qemu-char.c b/qemu-char.c
> index 1e882cf..368df2e 100644
> --- a/qemu-char.c
> +++ b/qemu-char.c
> @@ -665,7 +665,7 @@ static CharDriverState *qemu_chr_open_pipe(QemuOpts *opts)
>   	    close(fd_in);
>   	if (fd_out>= 0)
>   	    close(fd_out);
> -        TFR(fd_in = fd_out = open(filename, O_RDWR | O_BINARY));
> +        TFR(fd_in = fd_out = qemu_open(filename, O_RDWR | O_BINARY));
>           if (fd_in<  0)
>               return NULL;
>       }
> @@ -1217,7 +1217,7 @@ static CharDriverState *qemu_chr_open_tty(QemuOpts *opts)
>       CharDriverState *chr;
>       int fd;
>
> -    TFR(fd = open(filename, O_RDWR | O_NONBLOCK));
> +    TFR(fd = qemu_open(filename, O_RDWR | O_NONBLOCK));
>       if (fd<  0) {
>           return NULL;
>       }
> @@ -1355,7 +1355,7 @@ static CharDriverState *qemu_chr_open_pp(QemuOpts *opts)
>       ParallelCharDriver *drv;
>       int fd;
>
> -    TFR(fd = open(filename, O_RDWR));
> +    TFR(fd = qemu_open(filename, O_RDWR));
>       if (fd<  0)
>           return NULL;
>
> @@ -1424,7 +1424,7 @@ static CharDriverState *qemu_chr_open_pp(QemuOpts *opts)
>       CharDriverState *chr;
>       int fd;
>
> -    fd = open(filename, O_RDWR);
> +    fd = qemu_open(filename, O_RDWR);
>       if (fd<  0)
>           return NULL;
>

Patch

diff --git a/qemu-char.c b/qemu-char.c
index 1e882cf..368df2e 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -665,7 +665,7 @@  static CharDriverState *qemu_chr_open_pipe(QemuOpts *opts)
 	    close(fd_in);
 	if (fd_out >= 0)
 	    close(fd_out);
-        TFR(fd_in = fd_out = open(filename, O_RDWR | O_BINARY));
+        TFR(fd_in = fd_out = qemu_open(filename, O_RDWR | O_BINARY));
         if (fd_in < 0)
             return NULL;
     }
@@ -1217,7 +1217,7 @@  static CharDriverState *qemu_chr_open_tty(QemuOpts *opts)
     CharDriverState *chr;
     int fd;
 
-    TFR(fd = open(filename, O_RDWR | O_NONBLOCK));
+    TFR(fd = qemu_open(filename, O_RDWR | O_NONBLOCK));
     if (fd < 0) {
         return NULL;
     }
@@ -1355,7 +1355,7 @@  static CharDriverState *qemu_chr_open_pp(QemuOpts *opts)
     ParallelCharDriver *drv;
     int fd;
 
-    TFR(fd = open(filename, O_RDWR));
+    TFR(fd = qemu_open(filename, O_RDWR));
     if (fd < 0)
         return NULL;
 
@@ -1424,7 +1424,7 @@  static CharDriverState *qemu_chr_open_pp(QemuOpts *opts)
     CharDriverState *chr;
     int fd;
 
-    fd = open(filename, O_RDWR);
+    fd = qemu_open(filename, O_RDWR);
     if (fd < 0)
         return NULL;