[or-cvs] clean up the previous underflow check, and also point out
Roger Dingledine
arma at seul.org
Mon Nov 29 08:40:26 UTC 2004
Update of /home2/or/cvsroot/tor/src/common
In directory moria.mit.edu:/home2/arma/work/onion/cvs/tor/src/common
Modified Files:
log.c
Log Message:
clean up the previous underflow check, and also point out
yet another one that may be a problem. nick?
Index: log.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/common/log.c,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -d -r1.79 -r1.80
--- log.c 29 Nov 2004 06:43:21 -0000 1.79
+++ log.c 29 Nov 2004 08:40:24 -0000 1.80
@@ -122,10 +122,8 @@
size_t n;
int r;
char *end_of_prefix;
- if (buf_len < 2) { /* prevent integer underflow */
- tor_assert(0);
- exit(1);
- }
+
+ tor_assert(buf_len >= 2); /* prevent integer underflow */
buf_len -= 2; /* subtract 2 characters so we have room for \n\0 */
n = _log_prefix(buf, buf_len, severity);
@@ -141,7 +139,8 @@
r = tor_vsnprintf(buf+n,buf_len-n,format,ap);
if (r < 0) {
- n = buf_len-2;
+ n = buf_len-2; /* XXX is this line redundant with the -=2 above,
+ and also a source of underflow danger? */
strlcpy(buf+buf_len-TRUNCATED_STR_LEN-1, TRUNCATED_STR,
buf_len-(buf_len-TRUNCATED_STR_LEN-1));
} else {
More information about the tor-commits
mailing list