• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1From dad97d24d578dbefbebb41829b0ffb9e783cac7b Mon Sep 17 00:00:00 2001
2From: Ray Strode <rstrode@redhat.com>
3Date: Fri, 28 Oct 2022 11:21:04 -0400
4Subject: [PATCH] Revert "Handling collision between standard i/o file
5 descriptors and newly created ones"
6
7g_unix_open_pipe tries to avoid the standard io fd range
8when getting pipe fds. This turns out to be a bad idea because
9certain buggy programs rely on it using that range.
10
11This reverts commit d9ba6150909818beb05573f54f26232063492c5b
12
13Closes: #2795
14Reopens: #16
15
16Conflict:NA
17Reference:https://gitlab.gnome.org/GNOME/glib/-/commit/dad97d24d578dbefbebb41829b0ffb9e783cac7b
18
19---
20 glib/glib-unix.c | 24 ------------------------
21 1 file changed, 24 deletions(-)
22
23diff --git a/glib/glib-unix.c b/glib/glib-unix.c
24index 4710c51168..bc152d7663 100644
25--- a/glib/glib-unix.c
26+++ b/glib/glib-unix.c
27@@ -108,17 +108,6 @@ g_unix_open_pipe (int     *fds,
28     ecode = pipe2 (fds, pipe2_flags);
29     if (ecode == -1 && errno != ENOSYS)
30       return g_unix_set_error_from_errno (error, errno);
31-    /* Don't reassign pipes to stdin, stdout, stderr if closed meanwhile */
32-    else if (fds[0] < 3 || fds[1] < 3)
33-      {
34-        int old_fds[2] = { fds[0], fds[1] };
35-        gboolean result = g_unix_open_pipe (fds, flags, error);
36-        close (old_fds[0]);
37-        close (old_fds[1]);
38-
39-        if (!result)
40-          g_unix_set_error_from_errno (error, errno);
41-      }
42     else if (ecode == 0)
43       return TRUE;
44     /* Fall through on -ENOSYS, we must be running on an old kernel */
45@@ -127,19 +116,6 @@ g_unix_open_pipe (int     *fds,
46   ecode = pipe (fds);
47   if (ecode == -1)
48     return g_unix_set_error_from_errno (error, errno);
49-  /* Don't reassign pipes to stdin, stdout, stderr if closed meanwhile */
50-  else if (fds[0] < 3 || fds[1] < 3)
51-    {
52-      int old_fds[2] = { fds[0], fds[1] };
53-      gboolean result = g_unix_open_pipe (fds, flags, error);
54-      close (old_fds[0]);
55-      close (old_fds[1]);
56-
57-      if (!result)
58-        g_unix_set_error_from_errno (error, errno);
59-
60-      return result;
61-    }
62
63   if (flags == 0)
64     return TRUE;
65--
66GitLab
67
68