diff options
author | Nick Mathewson <nickm@torproject.org> | 2011-04-28 16:05:34 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2011-04-28 16:05:34 -0400 |
commit | 3055acbdbe914c31ca4825ed60b4cce6676bd61e (patch) | |
tree | 8d735e31d9b8bdd7b13d70901bd2434dadb31f1f /src/or/rephist.c | |
parent | 2c0258b69a232a7b11ecc999bee74dac1c1b1495 (diff) | |
parent | c1927d7d5f5dff5b8d7da5bd4e7a743eb06bcbb3 (diff) | |
download | tor-3055acbdbe914c31ca4825ed60b4cce6676bd61e.tar.gz tor-3055acbdbe914c31ca4825ed60b4cce6676bd61e.zip |
Merge remote-tracking branch 'sebastian/bug2497' into maint-0.2.2
Diffstat (limited to 'src/or/rephist.c')
-rw-r--r-- | src/or/rephist.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/or/rephist.c b/src/or/rephist.c index 5703e3edcd..02db247389 100644 --- a/src/or/rephist.c +++ b/src/or/rephist.c @@ -1525,10 +1525,15 @@ rep_hist_get_bandwidth_lines(void) size_t len; /* opt [dirreq-](read|write)-history yyyy-mm-dd HH:MM:SS (n s) n,n,n... */ - len = (67+21*NUM_TOTALS)*4; +/* The n,n,n part above. Largest representation of a uint64_t is 20 chars + * long, plus the comma. */ +#define MAX_HIST_VALUE_LEN 21*NUM_TOTALS + len = (67+MAX_HIST_VALUE_LEN)*4; buf = tor_malloc_zero(len); cp = buf; for (r=0;r<4;++r) { + char tmp[MAX_HIST_VALUE_LEN]; + size_t slen; switch (r) { case 0: b = write_array; @@ -1548,11 +1553,16 @@ rep_hist_get_bandwidth_lines(void) break; } tor_assert(b); + slen = rep_hist_fill_bandwidth_history(tmp, MAX_HIST_VALUE_LEN, b); + /* If we don't have anything to write, skip to the next entry. */ + if (slen == 0) + continue; format_iso_time(t, b->next_period-NUM_SECS_BW_SUM_INTERVAL); tor_snprintf(cp, len-(cp-buf), "%s %s (%d s) ", desc, t, NUM_SECS_BW_SUM_INTERVAL); cp += strlen(cp); - cp += rep_hist_fill_bandwidth_history(cp, len-(cp-buf), b); + strlcat(cp, tmp, len-(cp-buf)); + cp += slen; strlcat(cp, "\n", len-(cp-buf)); ++cp; } |