Don't start multiple blacklist checks per ve
authorDavid Barksdale <amatus@amat.us>
Sun, 8 Oct 2017 13:58:01 +0000 (08:58 -0500)
committerDavid Barksdale <amatus@amat.us>
Sun, 8 Oct 2017 14:51:06 +0000 (09:51 -0500)
This fixes a use-after-free I was seeing.

src/transport/gnunet-service-transport_validation.c

index 4a6d427becda1b53ff04fcc8dbb93d9b4eb80804..5a8539f72ea25c253264f84c28164ddac48f4c06 100644 (file)
@@ -697,7 +697,6 @@ revalidate_address (void *cls)
   struct GNUNET_TIME_Relative canonical_delay;
   struct GNUNET_TIME_Relative delay;
   struct GNUNET_TIME_Relative blocked_for;
-  struct GST_BlacklistCheck *bc;
   uint32_t rdelay;
 
   ve->revalidation_task = NULL;
@@ -784,15 +783,17 @@ revalidate_address (void *cls)
   GNUNET_STATISTICS_update (GST_stats,
                             gettext_noop ("# address revalidations started"), 1,
                             GNUNET_NO);
-  bc = GST_blacklist_test_allowed (&ve->address->peer,
-                                  ve->address->transport_name,
-                                   &transmit_ping_if_allowed,
-                                  ve,
-                                  NULL,
-                                  NULL);
-  if (NULL != bc)
-    ve->bc = bc;                /* only set 'bc' if 'transmit_ping_if_allowed' was not already
-                                 * called... */
+  if (NULL != ve->bc)
+  {
+    GST_blacklist_test_cancel (ve->bc);
+    ve->bc = NULL;
+  }
+  ve->bc = GST_blacklist_test_allowed (&ve->address->peer,
+                                       ve->address->transport_name,
+                                       &transmit_ping_if_allowed,
+                                       ve,
+                                       NULL,
+                                       NULL);
 }