[tor-commits] [tor/maint-0.4.0] Bug 30649: Check that machine is absent before warn

teor at torproject.org teor at torproject.org
Thu Sep 5 02:09:50 UTC 2019


commit 065f25c2ce092bbb0501ff9b7e2dbe6fb2f75699
Author: Mike Perry <mikeperry-git at torproject.org>
Date:   Thu May 30 15:15:01 2019 -0700

    Bug 30649: Check that machine is absent before warn
---
 src/core/or/circuitpadding.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/src/core/or/circuitpadding.c b/src/core/or/circuitpadding.c
index 0e3dc502c..352567edf 100644
--- a/src/core/or/circuitpadding.c
+++ b/src/core/or/circuitpadding.c
@@ -160,17 +160,25 @@ circpad_circuit_machineinfo_free_idx(circuit_t *circ, int idx)
   }
 }
 
-/** Free all the machineinfos in <b>circ</b> that match <b>machine_num</b>. */
-static void
+/**
+ * Free all the machineinfos in <b>circ</b> that match <b>machine_num</b>.
+ *
+ * Returns true if any machineinfos with that number were freed.
+ * False otherwise. */
+static int
 free_circ_machineinfos_with_machine_num(circuit_t *circ, int machine_num)
 {
+  int found = 0;
   FOR_EACH_CIRCUIT_MACHINE_BEGIN(i) {
     if (circ->padding_machine[i] &&
         circ->padding_machine[i]->machine_num == machine_num) {
       circpad_circuit_machineinfo_free_idx(circ, i);
       circ->padding_machine[i] = NULL;
+      found = 1;
     }
   } FOR_EACH_CIRCUIT_MACHINE_END;
+
+  return found;
 }
 
 /**
@@ -2439,7 +2447,10 @@ circpad_handle_padding_negotiate(circuit_t *circ, cell_t *cell)
 
   if (negotiate->command == CIRCPAD_COMMAND_STOP) {
     /* Free the machine corresponding to this machine type */
-    free_circ_machineinfos_with_machine_num(circ, negotiate->machine_type);
+    if (free_circ_machineinfos_with_machine_num(circ,
+                negotiate->machine_type)) {
+      goto done;
+    }
     log_fn(LOG_WARN, LD_CIRC,
           "Received circuit padding stop command for unknown machine.");
     goto err;





More information about the tor-commits mailing list