]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
sysdeps-unix: check fd before calling _dbus_fd_set_close_on_exec()
authorMike Gilbert <floppym@gentoo.org>
Sun, 27 Mar 2022 19:09:48 +0000 (15:09 -0400)
committerSimon McVittie <smcv@collabora.com>
Tue, 29 Mar 2022 11:52:32 +0000 (11:52 +0000)
If /proc/self/oom_score_adj does not exist, fd will invalid (-1).
Attempting to set the CLOEXEC flag will obviously fail, and we lose the
original errno value from open().

Bug: https://bugs.gentoo.org/834725
Signed-off-by: Mike Gilbert <floppym@gentoo.org>
dbus/dbus-sysdeps-util-unix.c

index 314ce64babef7411f61aefe8a577593a7a2065fa..8f079cbf280b1d287261f572728c60a492ceb05c 100644 (file)
@@ -1633,7 +1633,8 @@ _dbus_reset_oom_score_adj (const char **error_str_p)
   if (fd < 0)
     {
       fd = open ("/proc/self/oom_score_adj", O_RDWR);
-      _dbus_fd_set_close_on_exec (fd);
+      if (fd >= 0)
+        _dbus_fd_set_close_on_exec (fd);
     }
 
   if (fd >= 0)