aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2006-12-15 05:12:42 +0000
committerNick Mathewson <nickm@torproject.org>2006-12-15 05:12:42 +0000
commitfdb10ff0b59eaa60b66be5eed6077551d17ec331 (patch)
treec859e31808c36bf98d5541c2227e95afb21d3113 /src
parentc44dd3870e4fa46ad983632b873bcf7e4f973ff8 (diff)
downloadtor-fdb10ff0b59eaa60b66be5eed6077551d17ec331.tar
tor-fdb10ff0b59eaa60b66be5eed6077551d17ec331.tar.gz
r11580@Kushana: nickm | 2006-12-15 00:09:46 -0500
Resolve bug 369: Check for integer underflow when printing "bytes left" accounting numbers. Also fix a copyright date that I noticed while reading the bug. Also make a buffer big enough that strings will not get truncated. All are backport candidates. svn:r9115
Diffstat (limited to 'src')
-rw-r--r--src/or/config.c2
-rw-r--r--src/or/hibernate.c12
2 files changed, 9 insertions, 5 deletions
diff --git a/src/or/config.c b/src/or/config.c
index 2afabe480..5ab68a1d5 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -1585,7 +1585,7 @@ static void
print_usage(void)
{
printf(
-"Copyright 2001-2005 Roger Dingledine, Nick Mathewson.\n\n"
+"Copyright 2001-2006 Roger Dingledine, Nick Mathewson.\n\n"
"tor -f <torrc> [args]\n"
"See man page for options, or http://tor.eff.org/ for documentation.\n");
}
diff --git a/src/or/hibernate.c b/src/or/hibernate.c
index c0e6cf1b5..5a48138a2 100644
--- a/src/or/hibernate.c
+++ b/src/or/hibernate.c
@@ -949,10 +949,14 @@ getinfo_helper_accounting(control_connection_t *conn,
U64_PRINTF_ARG(n_bytes_written_in_interval));
} else if (!strcmp(question, "accounting/bytes-left")) {
uint64_t limit = get_options()->AccountingMax;
- *answer = tor_malloc(32);
- tor_snprintf(*answer, 32, U64_FORMAT" "U64_FORMAT,
- U64_PRINTF_ARG(limit - n_bytes_read_in_interval),
- U64_PRINTF_ARG(limit - n_bytes_written_in_interval));
+ uint64_t read_left = 0, write_left = 0;
+ if (n_bytes_read_in_interval < limit)
+ read_left = limit - n_bytes_read_in_interval;
+ if (n_bytes_written_in_interval < limit)
+ write_left = limit - n_bytes_written_in_interval;
+ *answer = tor_malloc(64);
+ tor_snprintf(*answer, 64, U64_FORMAT" "U64_FORMAT,
+ U64_PRINTF_ARG(read_left), U64_PRINTF_ARG(write_left));
} else if (!strcmp(question, "accounting/interval-start")) {
*answer = tor_malloc(ISO_TIME_LEN+1);
format_iso_time(*answer, interval_start_time);