[glib: 1/2] gspawn: Handle error opening /dev/null




commit f0e74a97e79f75676da867b1901fde26cc65ccd2
Author: Philip Withnall <pwithnall endlessos org>
Date:   Mon Oct 5 12:31:28 2020 +0100

    gspawn: Handle error opening /dev/null
    
    This is very unlikely to happen, but add error handling to mirror the
    other calls to `safe_open()`, and shut Coverity up.
    
    Coverity CID: #1430611
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>

 glib/gspawn.c | 3 +++
 1 file changed, 3 insertions(+)
---
diff --git a/glib/gspawn.c b/glib/gspawn.c
index c37ac7c84..b60073712 100644
--- a/glib/gspawn.c
+++ b/glib/gspawn.c
@@ -1451,6 +1451,9 @@ do_exec (gint                  child_err_report_fd,
   else if (stderr_to_null)
     {
       gint write_null = safe_open ("/dev/null", O_WRONLY);
+      if (write_null < 0)
+        write_err_and_exit (child_err_report_fd,
+                            CHILD_DUP2_FAILED);
       safe_dup2 (write_null, 2);
       close_and_invalidate (&write_null);
     }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]