]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Check spawn_func() return value
authorNick Mathewson <nickm@torproject.org>
Fri, 17 Jan 2014 17:04:53 +0000 (12:04 -0500)
committerNick Mathewson <nickm@torproject.org>
Fri, 17 Jan 2014 17:04:53 +0000 (12:04 -0500)
If we don't, we can wind up with a wedged cpuworker, and write to it
for ages and ages.

Found by skruffy.  This was a bug in 2dda97e8fd898757, a.k.a. svn
revision 402. It's been there since we have been using cpuworkers.

changes/bug4345 [new file with mode: 0644]
src/or/cpuworker.c

diff --git a/changes/bug4345 b/changes/bug4345
new file mode 100644 (file)
index 0000000..4975eea
--- /dev/null
@@ -0,0 +1,6 @@
+  o Minor bugfixes:
+    - Check return code on spawn_func() in cpuworker code, so that we don't
+      think we've spawned a nonworking cpuworker and write junk to it
+      forever. Fix for bug 4345; bugfix on all released Tor versions.
+      Found by "skruffy".
+
index ecf0d2035da553fa83f0f132bba5854a4fd5587e..2f9f527e97bfa45c6a71b7dd3accacc03b67e6d5 100644 (file)
@@ -528,7 +528,12 @@ spawn_cpuworker(void)
   tor_assert(SOCKET_OK(fdarray[1]));
 
   fd = fdarray[0];
-  spawn_func(cpuworker_main, (void*)fdarray);
+  if (spawn_func(cpuworker_main, (void*)fdarray) < 0) {
+    tor_close_socket(fdarray[0]);
+    tor_close_socket(fdarray[1]);
+    tor_free(fdarray);
+    return -1;
+  }
   log_debug(LD_OR,"just spawned a cpu worker.");
 #ifndef TOR_IS_MULTITHREADED
   tor_close_socket(fdarray[1]); /* don't need the worker's side of the pipe */