Commit 42c4670e authored by Nick Mathewson's avatar Nick Mathewson 🤹
Browse files

r18230@catbus: nickm | 2008-02-19 18:29:43 -0500

 Add a few asserts to catch possible errors found by veracode.


svn:r13598
parent 319c0d89
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -90,6 +90,7 @@ void
smartlist_add_all(smartlist_t *s1, const smartlist_t *s2)
{
  smartlist_ensure_capacity(s1, s1->num_used + s2->num_used);
  tor_assert(s1->capacity >= s1->num_used+s2->num_used);
  memcpy(s1->list + s1->num_used, s2->list, s2->num_used*sizeof(void*));
  s1->num_used += s2->num_used;
}
+4 −1
Original line number Diff line number Diff line
@@ -4753,7 +4753,10 @@ or_state_load(void)
      log_warn(LD_BUG, "Unable to parse state in \"%s\". Moving it aside "
               "to \"%s\".  This could be a bug in Tor; please tell "
               "the developers.", fname, fname2);
      (int)rename(fname, fname2);
      if (rename(fname, fname2) < 0) {
        log_warn(LD_BUG, "Weirdly, I couldn't even mode the state aside. The "
                 "OS gave an error of %s", strerror(errno));
      }
    }
    tor_free(fname2);
    tor_free(contents);
+3 −1
Original line number Diff line number Diff line
@@ -1133,6 +1133,8 @@ router_parse_entry_from_string(const char *s, const char *end,
      memcpy(cp, prepend_annotations, prepend_len);
      cp += prepend_len;
    }
    tor_assert(cp+(end-start_of_annotations) ==
               router->cache_info.signed_descriptor_body+len);
    memcpy(cp, start_of_annotations, end-start_of_annotations);
    router->cache_info.signed_descriptor_body[len] = '\0';
    tor_assert(strlen(router->cache_info.signed_descriptor_body) == len);