Browse Source

stop taking strlen of an uninitialized buffer
we were (are?) printing garbage in the rephist stats


svn:r2284

Roger Dingledine 21 years ago
parent
commit
a447570036
1 changed files with 3 additions and 2 deletions
  1. 3 2
      src/or/rephist.c

+ 3 - 2
src/or/rephist.c

@@ -266,9 +266,10 @@ void rep_hist_dump_stats(time_t now, int severity)
         or_history->n_conn_ok, or_history->n_conn_fail+or_history->n_conn_ok,
         or_history->n_conn_ok, or_history->n_conn_fail+or_history->n_conn_ok,
         upt, upt+downt, uptime*100.0);
         upt, upt+downt, uptime*100.0);
 
 
-    if (!strmap_isempty(or_history->link_history_map)) {
+    if (!strmap_isempty(or_history->link_history_map))
       strcpy(buffer, "    Good extend attempts: ");
       strcpy(buffer, "    Good extend attempts: ");
-    }
+    else
+      *buffer = '\0';
     len = strlen(buffer);
     len = strlen(buffer);
     for (lhist_it = strmap_iter_init(or_history->link_history_map);
     for (lhist_it = strmap_iter_init(or_history->link_history_map);
          !strmap_iter_done(lhist_it);
          !strmap_iter_done(lhist_it);