bus/dir-watch:Do not crash when reloading configuration with > 128 dirs
When dbus-daemon
sets more than 128 directories for XDG_DATA_DIRS
, during the first call to _set_watched_dirs_internal
, none of the elements in new_dirs
will be NULL
. If the memory after new_dirs
is also not NULL
, then num_wds
will be greater than 128. After sending SIGHUP
to dbus-daemon
, dbus-daemon
calls _set_watched_dirs_internal
for the second time. At this time, j
in if (dirs[j] && strcmp (new_dirs[i], dirs[j]) == 0)
may be greater than 128, which could cause strcmp
to trigger a coredump
.
We can limit the size of the array index to prevent this type of coredump from occurring
Fix: #481 (closed)