]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
activation test: Fix time-of-check/time-of-use bug waiting to happen
authorSimon McVittie <simon.mcvittie@collabora.co.uk>
Wed, 15 Feb 2017 17:24:14 +0000 (17:24 +0000)
committerSimon McVittie <simon.mcvittie@collabora.co.uk>
Thu, 16 Feb 2017 16:36:31 +0000 (16:36 +0000)
Creating a directory is atomic, stat'ing it to see whether to remove
it is very much not.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=99828
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
bus/activation.c

index fb603467799e2ac058cdac5a3ed1dd1f3795b7f7..5b439b370566a4bc8c8735ca2d6a8a7bafe6f4a9 100644 (file)
@@ -2410,21 +2410,8 @@ out:
 static dbus_bool_t
 init_service_reload_test (DBusString *dir)
 {
-  DBusStat stat_buf;
-
-  if (!_dbus_stat (dir, &stat_buf, NULL))
-    {
-      if (!_dbus_create_directory (dir, NULL))
-        return FALSE;
-    }
-  else
-    {
-      if (!test_remove_directory (dir))
-        return FALSE;
-
-      if (!_dbus_create_directory (dir, NULL))
-        return FALSE;
-    }
+  if (!_dbus_create_directory (dir, NULL))
+    return FALSE;
 
   /* Create one initial file */
   if (!test_create_service_file (dir, SERVICE_FILE_1, SERVICE_NAME_1, "exec-1"))
@@ -2613,6 +2600,9 @@ bus_activation_service_reload_test (const DBusString *test_data_dir)
       /* Do nothing? */
     }
 
+  if (!cleanup_service_reload_test (&directory))
+    return FALSE;
+
   /* Do OOM tests */
   if (!init_service_reload_test (&directory))
     _dbus_assert_not_reached ("could not initiate service reload test");