summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Gilbert <floppym@gentoo.org>2022-03-27 15:09:48 -0400
committerSimon McVittie <smcv@collabora.com>2022-09-13 12:24:13 +0100
commitd5f9a6e075d3ce13bb5fd8f64bd4317220503cb0 (patch)
tree28d3e46e18c4a83a407846a8f18808b9acf7633c
parent0d3ca74340b9468c0d9b979b4f6dd20fc903e92a (diff)
downloaddbus-d5f9a6e075d3ce13bb5fd8f64bd4317220503cb0.tar.gz
sysdeps-unix: check fd before calling _dbus_fd_set_close_on_exec()
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> (cherry picked from commit 769a0462befb9829594a76e675526aba8579317e) Backported-from: dbus!285
-rw-r--r--dbus/dbus-sysdeps-util-unix.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/dbus/dbus-sysdeps-util-unix.c b/dbus/dbus-sysdeps-util-unix.c
index 314ce64b..8f079cbf 100644
--- a/dbus/dbus-sysdeps-util-unix.c
+++ b/dbus/dbus-sysdeps-util-unix.c
@@ -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)