]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
kqueue set_watched_dirs: fix termination condition
authorWill Thompson <will.thompson@collabora.co.uk>
Thu, 20 May 2010 15:08:33 +0000 (16:08 +0100)
committerWill Thompson <will.thompson@collabora.co.uk>
Fri, 21 May 2010 10:21:20 +0000 (11:21 +0100)
num_fds is the number of elements of dirs currently in use. This bug
meant that encountering a previously un-watched directory would cause j
to increment forever, and so dirs[j] would eventually segfault.

(I've checked the corresponding code for inotify, and it's correct. I
wonder if some of the duplication could be eliminated.)

Thanks to Pablo Martí Gamboa <pmarti@warp.es> for reporting this issue!

bus/dir-watch-kqueue.c

index 4a01b748a6cc8458736edd528eed19a51d744882..4e436eb13f9cb6ad7d1c5667e29a5de103de2a66 100644 (file)
@@ -169,7 +169,7 @@ bus_set_watched_dirs (BusContext *context, DBusList **directories)
    */
   for (i = 0; new_dirs[i]; i++)
     {
-      for (j = 0; i < num_fds; j++)
+      for (j = 0; j < num_fds; j++)
         {
           if (dirs[j] && strcmp (new_dirs[i], dirs[j]) == 0)
             {