summaryrefslogtreecommitdiff
path: root/src/or/hibernate.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2006-06-24 04:57:59 +0000
committerRoger Dingledine <arma@torproject.org>2006-06-24 04:57:59 +0000
commitf88d555ce07489e1e5294e334496250992860cbc (patch)
tree63b63086a0adc63babb5c2810796a9a058477962 /src/or/hibernate.c
parentb4b8da5d230030db5d32e55fb8cecadea67f8cbc (diff)
downloadtor-f88d555ce07489e1e5294e334496250992860cbc.tar.gz
tor-f88d555ce07489e1e5294e334496250992860cbc.zip
refuse to write an iso_time which we can't parse, when dumping
bandwidth state. this fixes the particular incident in bug 308, but the general issue remains. svn:r6684
Diffstat (limited to 'src/or/hibernate.c')
-rw-r--r--src/or/hibernate.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/or/hibernate.c b/src/or/hibernate.c
index da74e98dd2..d4e6ceb078 100644
--- a/src/or/hibernate.c
+++ b/src/or/hibernate.c
@@ -536,7 +536,7 @@ accounting_set_wakeup_time(void)
#define BW_ACCOUNTING_VERSION 1
/** Save all our bandwidth tracking information to disk. Return 0 on
- * success, -1 on failure*/
+ * success, -1 on failure. */
int
accounting_record_bandwidth_usage(time_t now)
{
@@ -545,11 +545,18 @@ accounting_record_bandwidth_usage(time_t now)
char time1[ISO_TIME_LEN+1];
char time2[ISO_TIME_LEN+1];
char *cp = buf;
+ time_t tmp;
/* Format is:
Version\nTime\nTime\nRead\nWrite\nSeconds\nExpected-Rate\n */
format_iso_time(time1, interval_start_time);
format_iso_time(time2, now);
+ /* now check to see if they're valid times -- if they're not,
+ * and we write them, then tor will refuse to start next time. */
+ if (parse_iso_time(time1, &tmp) || parse_iso_time(time2, &tmp)) {
+ log_warn(LD_ACCT, "Created a time that we refused to parse.");
+ return -1;
+ }
tor_snprintf(cp, sizeof(buf),
"%d\n%s\n%s\n"U64_FORMAT"\n"U64_FORMAT"\n%lu\n%lu\n",
BW_ACCOUNTING_VERSION,