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

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


svn:r13598
This commit is contained in:
Nick Mathewson 2008-02-19 23:29:45 +00:00
parent 319c0d8933
commit 42c4670e27
3 changed files with 8 additions and 2 deletions

View File

@ -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;
}

View File

@ -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);

View File

@ -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);