]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
sr: BUG() on NULL sr_state before doing a state_query_*()
authorteor <teor@torproject.org>
Tue, 12 Mar 2019 01:09:48 +0000 (11:09 +1000)
committerteor <teor@torproject.org>
Tue, 12 Mar 2019 01:14:30 +0000 (11:14 +1000)
Part of #29706.

src/or/shared_random_state.c

index 22a503b89ba2ade9bd763097c3e37328420b2d07..5011b5c7f3cbc10d9e232bf2f0424858e73d97eb 100644 (file)
@@ -857,6 +857,9 @@ state_query_get_commit(const char *rsa_fpr)
 static void *
 state_query_get_(sr_state_object_t obj_type, const void *data)
 {
+  if (BUG(!sr_state))
+    return NULL;
+
   void *obj = NULL;
 
   switch (obj_type) {
@@ -890,6 +893,9 @@ state_query_get_(sr_state_object_t obj_type, const void *data)
 static void
 state_query_put_(sr_state_object_t obj_type, void *data)
 {
+  if (BUG(!sr_state))
+    return;
+
   switch (obj_type) {
   case SR_STATE_OBJ_COMMIT:
   {
@@ -939,6 +945,9 @@ state_query_put_(sr_state_object_t obj_type, void *data)
 static void
 state_query_del_all_(sr_state_object_t obj_type)
 {
+  if (BUG(!sr_state))
+    return;
+
   switch (obj_type) {
   case SR_STATE_OBJ_COMMIT:
   {
@@ -967,6 +976,9 @@ state_query_del_(sr_state_object_t obj_type, void *data)
 {
   (void) data;
 
+  if (BUG(!sr_state))
+    return;
+
   switch (obj_type) {
   case SR_STATE_OBJ_PREVSRV:
     tor_free(sr_state->previous_srv);