]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Expand the event_mask field in controller conns to 64 bits
authorNick Mathewson <nickm@torproject.org>
Mon, 8 Sep 2014 19:15:05 +0000 (15:15 -0400)
committerNick Mathewson <nickm@torproject.org>
Mon, 8 Sep 2014 19:16:02 +0000 (15:16 -0400)
Back in 078d6bcd, we added an event number 0x20, but we didn't make
the event_mask field big enough to compensate.

Patch by "teor". Fixes 13085; bugfix on 0.2.5.1-alpha.

changes/bug13085 [new file with mode: 0644]
src/or/control.c
src/or/control.h
src/or/or.h

diff --git a/changes/bug13085 b/changes/bug13085
new file mode 100644 (file)
index 0000000..a46457c
--- /dev/null
@@ -0,0 +1,3 @@
+  o Minor bugfixes (controller):
+    - Actually send TRANSPORT_LAUNCHED and HS_DESC events to controllers.
+      Fixes bug 13085; bugfix on 0.2.5.1-alpha. Patch by "teor".
index 4a6b18d02ad0f40adfece4a31ab467aead24e426..9378f38f406206f1f689a0fa0fd8181942736f22 100644 (file)
@@ -582,7 +582,7 @@ send_control_event_string,(uint16_t event, event_format_t which,
         conn->state == CONTROL_CONN_STATE_OPEN) {
       control_connection_t *control_conn = TO_CONTROL_CONN(conn);
 
-      if (control_conn->event_mask & (1<<event)) {
+      if (control_conn->event_mask & (((event_mask_t)1)<<event)) {
         int is_err = 0;
         connection_write_to_buf(msg, strlen(msg), TO_CONN(control_conn));
         if (event == EVENT_ERR_MSG)
@@ -950,7 +950,7 @@ handle_control_setevents(control_connection_t *conn, uint32_t len,
                          const char *body)
 {
   int event_code = -1;
-  uint32_t event_mask = 0;
+  event_mask_t event_mask = 0;
   smartlist_t *events = smartlist_new();
 
   (void) len;
@@ -978,7 +978,7 @@ handle_control_setevents(control_connection_t *conn, uint32_t len,
           return 0;
         }
       }
-      event_mask |= (1 << event_code);
+      event_mask |= (((event_mask_t)1) << event_code);
     }
   SMARTLIST_FOREACH_END(ev);
   SMARTLIST_FOREACH(events, char *, e, tor_free(e));
@@ -2880,7 +2880,7 @@ handle_control_resolve(control_connection_t *conn, uint32_t len,
   int is_reverse = 0;
   (void) len; /* body is nul-terminated; it's safe to ignore the length */
 
-  if (!(conn->event_mask & ((uint32_t)1L<<EVENT_ADDRMAP))) {
+  if (!(conn->event_mask & (((event_mask_t)1)<<EVENT_ADDRMAP))) {
     log_warn(LD_CONTROL, "Controller asked us to resolve an address, but "
              "isn't listening for ADDRMAP events.  It probably won't see "
              "the answer.");
index 68a6c244d046daf662281746b77b9179baf54a05..494f04b3bd6ff358b82a038f8d84b36524468307 100644 (file)
@@ -156,8 +156,8 @@ void control_free_all(void);
 #define EVENT_TRANSPORT_LAUNCHED      0x0020
 #define EVENT_HS_DESC                 0x0021
 #define EVENT_MAX_                    0x0021
-/* If EVENT_MAX_ ever hits 0x0040, we need to make the mask into a
- * different structure. */
+/* If EVENT_MAX_ ever hits 0x003F, we need to make the mask into a
+ * different structure, as it can only handle a maximum left shift of 1<<63. */
 
 /* Used only by control.c and test.c */
 STATIC size_t write_escaped_data(const char *data, size_t len, char **out);
index 0f1457f78331b46edae9e87b81d60f40f7e78a0a..160958771796a7bae8b8e38517b5a51f19e056a1 100644 (file)
@@ -1737,8 +1737,9 @@ typedef struct dir_connection_t {
 typedef struct control_connection_t {
   connection_t base_;
 
-  uint32_t event_mask; /**< Bitfield: which events does this controller
-                        * care about? */
+  uint64_t event_mask; /**< Bitfield: which events does this controller
+                        * care about?
+                        * EVENT_MAX_ is >31, so we need a 64 bit mask */
 
   /** True if we have sent a protocolinfo reply on this connection. */
   unsigned int have_sent_protocolinfo:1;