mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-05-09 07:18:03 +02:00
bus/dir-watch: Do not crash with > 128 dirs
Without this running, dbus-daemon with long XDG_DATA_DIRS will crash on out-of-bounds write: $ XDG_DATA_DIRS=$(seq -f "/foo/%g" -s ':' 129) dbus-daemon --session *** stack smashing detected ***: terminated (cherry picked from commitb551b3e973) Backported-from: dbus!302 (cherry picked from commit9e8fe0718c)
This commit is contained in:
parent
0a516ae5a7
commit
5fd9680e13
2 changed files with 12 additions and 2 deletions
|
|
@ -108,12 +108,17 @@ _set_watched_dirs_internal (DBusList **directories)
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
link = _dbus_list_get_first_link (directories);
|
link = _dbus_list_get_first_link (directories);
|
||||||
while (link != NULL)
|
while (link != NULL && i < MAX_DIRS_TO_WATCH)
|
||||||
{
|
{
|
||||||
new_dirs[i++] = (char *)link->data;
|
new_dirs[i++] = (char *)link->data;
|
||||||
link = _dbus_list_get_next_link (directories, link);
|
link = _dbus_list_get_next_link (directories, link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (link != NULL)
|
||||||
|
{
|
||||||
|
_dbus_warn ("Too many directories to watch them all, only watching first %d.", MAX_DIRS_TO_WATCH);
|
||||||
|
}
|
||||||
|
|
||||||
/* Look for directories in both the old and new sets, if
|
/* Look for directories in both the old and new sets, if
|
||||||
* we find one, move its data into the new set.
|
* we find one, move its data into the new set.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -218,12 +218,17 @@ bus_set_watched_dirs (BusContext *context, DBusList **directories)
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
link = _dbus_list_get_first_link (directories);
|
link = _dbus_list_get_first_link (directories);
|
||||||
while (link != NULL)
|
while (link != NULL && i < MAX_DIRS_TO_WATCH)
|
||||||
{
|
{
|
||||||
new_dirs[i++] = (char *)link->data;
|
new_dirs[i++] = (char *)link->data;
|
||||||
link = _dbus_list_get_next_link (directories, link);
|
link = _dbus_list_get_next_link (directories, link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (link != NULL)
|
||||||
|
{
|
||||||
|
_dbus_warn ("Too many directories to watch them all, only watching first %d.", MAX_DIRS_TO_WATCH);
|
||||||
|
}
|
||||||
|
|
||||||
/* Look for directories in both the old and new sets, if
|
/* Look for directories in both the old and new sets, if
|
||||||
* we find one, move its data into the new set.
|
* we find one, move its data into the new set.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue