[or-cvs] Replace an infinite-stack-recursion bug with a generate-inf...

Nick Mathewson nickm at seul.org
Sun Apr 17 22:52:05 UTC 2005


Update of /home/or/cvsroot/tor/src/or
In directory moria.mit.edu:/tmp/cvs-serv29558/src/or

Modified Files:
	control.c 
Log Message:
Replace an infinite-stack-recursion bug with a generate-infinite-debug-messages bug.  Maybe it isnt such a good idea to send LOG_DEBUG messages to the controller after all?

Index: control.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/control.c,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -d -r1.77 -r1.78
--- control.c	11 Apr 2005 02:52:09 -0000	1.77
+++ control.c	17 Apr 2005 22:52:02 -0000	1.78
@@ -319,6 +319,8 @@
   size_t buflen;
   char *buf;
 
+  tor_assert(event >= _EVENT_MIN && event <= _EVENT_MAX);
+
   buflen = len + 2;
   buf = tor_malloc_zero(buflen);
   set_uint16(buf, htons(event));
@@ -1159,19 +1161,27 @@
 void
 control_event_logmsg(int severity, const char *msg)
 {
-  int oldlog = EVENT_IS_INTERESTING(EVENT_LOG_OBSOLETE) &&
+  static int sending_logmsg=0;
+  int oldlog, event;
+
+  if (sending_logmsg)
+    return;
+
+  oldlog = EVENT_IS_INTERESTING(EVENT_LOG_OBSOLETE) &&
     (severity == LOG_NOTICE || severity == LOG_WARN || severity == LOG_ERR);
-  int event = log_severity_to_event(severity);
+  event = log_severity_to_event(severity);
 
   if (event<0 || !EVENT_IS_INTERESTING(event))
     event = 0;
 
   if (oldlog || event) {
     size_t len = strlen(msg);
+    sending_logmsg = 1;
     if (event)
       send_control_event(event, (uint32_t)(len+1), msg);
     if (oldlog)
       send_control_event(EVENT_LOG_OBSOLETE, (uint32_t)(len+1), msg);
+    sending_logmsg = 0;
   }
 }
 
@@ -1228,4 +1238,3 @@
 
   return 0;
 }
-



More information about the tor-commits mailing list