[tor-commits] [tor/master] Use uint64_t for total length of dumped descriptors, nad be careful about overflows in the loop in dump_desc_fifo_add_and_clean()

nickm at torproject.org nickm at torproject.org
Thu Jun 30 15:18:32 UTC 2016


commit 603f483092778786e29944acf71a608bfa21650b
Author: Andrea Shepard <andrea at torproject.org>
Date:   Wed Jun 29 22:40:28 2016 +0000

    Use uint64_t for total length of dumped descriptors, nad be careful about overflows in the loop in dump_desc_fifo_add_and_clean()
---
 src/or/routerparse.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index 5f1dde4..afdfcbd 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));





More information about the tor-commits mailing list