diff options
author | Nick Mathewson <nickm@torproject.org> | 2004-10-27 21:30:47 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2004-10-27 21:30:47 +0000 |
commit | f8771625c6329b4de302f9e213177d2512b13c3f (patch) | |
tree | 61d3a09067142783960d29c29e1fc85ef17ada28 /src/or/rephist.c | |
parent | 2fbf31533ba595c3c0ba6a0c1349208fbdfb498a (diff) | |
download | tor-f8771625c6329b4de302f9e213177d2512b13c3f.tar tor-f8771625c6329b4de302f9e213177d2512b13c3f.tar.gz |
Check return of tor_snprintf
svn:r2616
Diffstat (limited to 'src/or/rephist.c')
-rw-r--r-- | src/or/rephist.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/or/rephist.c b/src/or/rephist.c index 506264928..790ad4b1c 100644 --- a/src/or/rephist.c +++ b/src/or/rephist.c @@ -237,6 +237,7 @@ void rep_hist_dump_stats(time_t now, int severity) double uptime; char buffer[2048]; size_t len; + int r; unsigned long upt, downt; routerinfo_t *r; @@ -279,14 +280,14 @@ void rep_hist_dump_stats(time_t now, int severity) name2 = "(unknown)"; link_history = (link_history_t*) link_history_p; -/* XXX009 tor_snprintf can return -1 for error also. need to detect. */ - len += tor_snprintf(buffer+len, 2048-len, "%s(%ld/%ld); ", name2, + + r = tor_snprintf(buffer+len, 2048-len, "%s(%ld/%ld); ", name2, link_history->n_extend_ok, link_history->n_extend_ok+link_history->n_extend_fail); - if (len >= 2048) { - buffer[2047]='\0'; + if (r<0) break; - } + else + len += r; } log(severity, "%s", buffer); } |