aboutsummaryrefslogtreecommitdiff
path: root/src/or/hibernate.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2012-01-11 14:02:59 -0500
committerNick Mathewson <nickm@torproject.org>2012-01-16 15:03:44 -0500
commit9c29369a04cdf47bd882579331577d82305bf785 (patch)
tree4a9752c89feb50c9fced1d18fdb4bbf24e3d9b72 /src/or/hibernate.c
parentcc02823d7f6acbc3fa8ea87e5646921100796f10 (diff)
downloadtor-9c29369a04cdf47bd882579331577d82305bf785.tar
tor-9c29369a04cdf47bd882579331577d82305bf785.tar.gz
Convert instances of tor_malloc+tor_snprintf into tor_asprintf
These were found by looking for tor_snprintf() instances that were preceeded closely by tor_malloc(), though I probably converted some more snprintfs as well. (In every case, make sure that the length variable (if any) is removed, renamed, or lowered, so that anything else that might have assumed a longer buffer doesn't exist.)
Diffstat (limited to 'src/or/hibernate.c')
-rw-r--r--src/or/hibernate.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/or/hibernate.c b/src/or/hibernate.c
index 803f7f576..917bd8205 100644
--- a/src/or/hibernate.c
+++ b/src/or/hibernate.c
@@ -976,8 +976,7 @@ getinfo_helper_accounting(control_connection_t *conn,
else
*answer = tor_strdup("awake");
} else if (!strcmp(question, "accounting/bytes")) {
- *answer = tor_malloc(32);
- tor_snprintf(*answer, 32, U64_FORMAT" "U64_FORMAT,
+ tor_asprintf(answer, U64_FORMAT" "U64_FORMAT,
U64_PRINTF_ARG(n_bytes_read_in_interval),
U64_PRINTF_ARG(n_bytes_written_in_interval));
} else if (!strcmp(question, "accounting/bytes-left")) {
@@ -987,8 +986,7 @@ getinfo_helper_accounting(control_connection_t *conn,
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,
+ tor_asprintf(answer, 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);