[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] Check return of tor_snprintf
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/tmp/cvs-serv17138/src/or
Modified Files:
rephist.c
Log Message:
Check return of tor_snprintf
Index: rephist.c
===================================================================
RCS file: /home/or/cvsroot/src/or/rephist.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- rephist.c 27 Oct 2004 06:48:16 -0000 1.34
+++ rephist.c 27 Oct 2004 21:30:47 -0000 1.35
@@ -237,6 +237,7 @@
double uptime;
char buffer[2048];
size_t len;
+ int r;
unsigned long upt, downt;
routerinfo_t *r;
@@ -279,14 +280,14 @@
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);
}