summaryrefslogtreecommitdiff
path: root/src/or/routerparse.c
diff options
context:
space:
mode:
authorAndrea Shepard <andrea@torproject.org>2016-06-29 22:40:28 +0000
committerAndrea Shepard <andrea@torproject.org>2016-06-30 07:03:25 +0000
commit603f483092778786e29944acf71a608bfa21650b (patch)
treee36a274bef3bd7655d79634c762c187e86c37980 /src/or/routerparse.c
parent824ee581b02d83d331506ab699ba3110f43595cb (diff)
downloadtor-603f483092778786e29944acf71a608bfa21650b.tar.gz
tor-603f483092778786e29944acf71a608bfa21650b.zip
Use uint64_t for total length of dumped descriptors, nad be careful about overflows in the loop in dump_desc_fifo_add_and_clean()
Diffstat (limited to 'src/or/routerparse.c')
-rw-r--r--src/or/routerparse.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index 5f1dde4dc9..afdfcbd403 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -590,7 +590,7 @@ static int check_signature_token(const char *digest,
/** List of dumped descriptors for FIFO cleanup purposes */
STATIC smartlist_t *descs_dumped = NULL;
/** Total size of dumped descriptors for FIFO cleanup */
-STATIC size_t len_descs_dumped = 0;
+STATIC uint64_t len_descs_dumped = 0;
/*
* One entry in the list of dumped descriptors; filename dumped to, length
@@ -614,7 +614,7 @@ dump_desc_fifo_add_and_clean(char *filename, const uint8_t *digest_sha256,
size_t len)
{
dumped_desc_t *ent = NULL, *tmp;
- size_t max_len;
+ uint64_t max_len;
tor_assert(filename != NULL);
tor_assert(digest_sha256 != NULL);
@@ -635,7 +635,7 @@ dump_desc_fifo_add_and_clean(char *filename, const uint8_t *digest_sha256,
/* Do we need to do some cleanup? */
max_len = get_options()->MaxUnparseableDescSizeToLog;
/* Iterate over the list until we've freed enough space */
- while (len_descs_dumped + len > max_len &&
+ while (len > max_len - len_descs_dumped &&
smartlist_len(descs_dumped) > 0) {
/* Get the oldest thing on the list */
tmp = (dumped_desc_t *)(smartlist_get(descs_dumped, 0));