[or-cvs] prevent integer underflow

Roger Dingledine arma at seul.org
Mon Nov 29 06:43:23 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:
prevent integer underflow
(not currently exploitable, ilja and i think)


Index: log.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/common/log.c,v
retrieving revision 1.78
retrieving revision 1.79
diff -u -d -r1.78 -r1.79
--- log.c	28 Nov 2004 11:39:51 -0000	1.78
+++ log.c	29 Nov 2004 06:43:21 -0000	1.79
@@ -122,6 +122,10 @@
   size_t n;
   int r;
   char *end_of_prefix;
+  if (buf_len < 2) { /* prevent integer underflow */
+    tor_assert(0);
+    exit(1);
+  }
   buf_len -= 2; /* subtract 2 characters so we have room for \n\0 */
 
   n = _log_prefix(buf, buf_len, severity);



More information about the tor-commits mailing list