[or-cvs] r9115: Resolve bug 369: Check for integer underflow when printing " (in tor/trunk: . src/or)

nickm at seul.org nickm at seul.org
Fri Dec 15 05:12:47 UTC 2006


Author: nickm
Date: 2006-12-15 00:12:42 -0500 (Fri, 15 Dec 2006)
New Revision: 9115

Modified:
   tor/trunk/
   tor/trunk/ChangeLog
   tor/trunk/src/or/config.c
   tor/trunk/src/or/hibernate.c
Log:
 r11580 at 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.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r11580] on c95137ef-5f19-0410-b913-86e773d04f59

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2006-12-15 01:11:54 UTC (rev 9114)
+++ tor/trunk/ChangeLog	2006-12-15 05:12:42 UTC (rev 9115)
@@ -51,6 +51,9 @@
   o Controller bugfixes:
     - Report the circuit number correctly in STREAM CLOSED events. (Bug
       reported by Mike Perry.)
+    - Do not report bizarre values for results of accounting GETINFOs
+      when the last second's write or read exceeds the alloted bandwidth.
+      (Bug 329.)
 
 
 Changes in version 0.1.2.4-alpha - 2006-12-03

Modified: tor/trunk/src/or/config.c
===================================================================
--- tor/trunk/src/or/config.c	2006-12-15 01:11:54 UTC (rev 9114)
+++ tor/trunk/src/or/config.c	2006-12-15 05:12:42 UTC (rev 9115)
@@ -1585,7 +1585,7 @@
 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");
 }

Modified: tor/trunk/src/or/hibernate.c
===================================================================
--- tor/trunk/src/or/hibernate.c	2006-12-15 01:11:54 UTC (rev 9114)
+++ tor/trunk/src/or/hibernate.c	2006-12-15 05:12:42 UTC (rev 9115)
@@ -949,10 +949,14 @@
                  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);



More information about the tor-commits mailing list