From e94e989133c666aa09e3303245d6ec4d2be74589 Mon Sep 17 00:00:00 2001 From: hongjinghao Date: Wed, 21 Feb 2024 11:22:21 +0800 Subject: [PATCH] sync patch from dbus community --- ...t-crash-when-reloading-configuration.patch | 66 +++++++++++++++++++ dbus.spec | 6 +- 2 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 backport-Do-not-crash-when-reloading-configuration.patch diff --git a/backport-Do-not-crash-when-reloading-configuration.patch b/backport-Do-not-crash-when-reloading-configuration.patch new file mode 100644 index 0000000..bf4802f --- /dev/null +++ b/backport-Do-not-crash-when-reloading-configuration.patch @@ -0,0 +1,66 @@ +From c3b1e4daa5b0ed5729f0f12bc6a3ba50a391f7f6 Mon Sep 17 00:00:00 2001 +From: hongjinghao +Date: Thu, 4 Jan 2024 15:15:53 +0800 +Subject: [PATCH] Do not crash when reloading configuration with > 128 dirs + +When `dbus-daemon` sets more than 128 directories for `XDG_DATA_DIRS`, +none of the elements in `new_dirs` will be `NULL`, which resulted in +these loops reading out-of-bounds (undefined behaviour). In practice +this led to a crash. + +To avoid this, make sure to stop iteration at the end of the array. + +[smcv: Expanded commit message] +Resolves: dbus/dbus#481 +--- + bus/dir-watch-inotify.c | 4 ++-- + bus/dir-watch-kqueue.c | 4 ++-- + 2 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/bus/dir-watch-inotify.c b/bus/dir-watch-inotify.c +index 77b2d5a92..4f269777f 100644 +--- a/bus/dir-watch-inotify.c ++++ b/bus/dir-watch-inotify.c +@@ -131,7 +131,7 @@ _set_watched_dirs_internal (BusContext *context, + /* Look for directories in both the old and new sets, if + * we find one, move its data into the new set. + */ +- for (i = 0; new_dirs[i]; i++) ++ for (i = 0; i < MAX_DIRS_TO_WATCH && new_dirs[i]; i++) + { + for (j = 0; j < num_wds; j++) + { +@@ -160,7 +160,7 @@ _set_watched_dirs_internal (BusContext *context, + } + } + +- for (i = 0; new_dirs[i]; i++) ++ for (i = 0; i < MAX_DIRS_TO_WATCH && new_dirs[i]; i++) + { + if (new_wds[i] == -1) + { +diff --git a/bus/dir-watch-kqueue.c b/bus/dir-watch-kqueue.c +index b419606e3..07b505c99 100644 +--- a/bus/dir-watch-kqueue.c ++++ b/bus/dir-watch-kqueue.c +@@ -235,7 +235,7 @@ bus_set_watched_dirs (BusContext *context, DBusList **directories) + /* Look for directories in both the old and new sets, if + * we find one, move its data into the new set. + */ +- for (i = 0; new_dirs[i]; i++) ++ for (i = 0; i < MAX_DIRS_TO_WATCH && new_dirs[i]; i++) + { + for (j = 0; j < num_fds; j++) + { +@@ -264,7 +264,7 @@ bus_set_watched_dirs (BusContext *context, DBusList **directories) + } + } + +- for (i = 0; new_dirs[i]; i++) ++ for (i = 0; i < MAX_DIRS_TO_WATCH && new_dirs[i]; i++) + { + if (new_fds[i] == -1) + { +-- +GitLab + diff --git a/dbus.spec b/dbus.spec index a076274..b63fb3a 100644 --- a/dbus.spec +++ b/dbus.spec @@ -1,7 +1,7 @@ Name: dbus Epoch: 1 Version: 1.14.8 -Release: 1 +Release: 2 Summary: System Message Bus License: AFLv3.0 or GPLv2+ URL: http://www.freedesktop.org/Software/dbus/ @@ -12,6 +12,7 @@ Patch0001: bugfix-let-systemd-restart-dbus-when-the-it-enters-failed.patch Patch0002: print-load-average-when-activate-service-timeout.patch Patch6001: backport-tools-Use-Python3-for-GetAllMatchRules.patch +Patch6002: backport-Do-not-crash-when-reloading-configuration.patch BuildRequires: systemd-devel expat-devel libselinux-devel audit-libs-devel doxygen xmlto cmake BuildRequires: autoconf-archive libtool libX11-devel libcap-ng-devel libxslt @@ -224,6 +225,9 @@ fi %exclude %{_pkgdocdir}/README %changelog +* Wed Feb 21 2024 hongjinghao - 1:1.14.8-2 +- add backport-Do-not-crash-when-reloading-configuration.patch + * Fri Jul 14 2023 hongjinghao - 1:1.14.8-1 - Update to 1.14.8 -- Gitee