[glib: 11/19] gbacktrace: Fix fcntl command arguments not being checked
- From: Philip Withnall <pwithnall src gnome org>
 
- To: commits-list gnome org
 
- Cc: 
 
- Subject: [glib: 11/19] gbacktrace: Fix fcntl command arguments not being checked
 
- Date: Mon, 18 Oct 2021 11:03:35 +0000 (UTC)
 
commit e9adcd8f7fb764e301a725c2484212d506948835
Author: Egor Bychin <e bychin drweb com>
Date:   Mon Oct 11 14:08:34 2021 +0300
    gbacktrace: Fix fcntl command arguments not being checked
 glib/gbacktrace.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
---
diff --git a/glib/gbacktrace.c b/glib/gbacktrace.c
index 61810735f..eb9ec8d66 100644
--- a/glib/gbacktrace.c
+++ b/glib/gbacktrace.c
@@ -340,7 +340,11 @@ stack_trace (const char * const *args)
       /* Save stderr for printing failure below */
       int old_err = dup (2);
       if (old_err != -1)
-        fcntl (old_err, F_SETFD, fcntl (old_err, F_GETFD) | FD_CLOEXEC);
+       {
+         int getfd = fcntl (old_err, F_GETFD);
+         if (getfd != -1)
+           (void) fcntl (old_err, F_SETFD, getfd | FD_CLOEXEC);
+       }
 
       close (0); dup (in_fd[0]);   /* set the stdin to the in pipe */
       close (1); dup (out_fd[1]);  /* set the stdout to the out pipe */
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]