]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Make _SC_OPEN_MAX actually get used when closing fds before exec.
authorNick Mathewson <nickm@torproject.org>
Mon, 11 Feb 2013 21:27:35 +0000 (16:27 -0500)
committerNick Mathewson <nickm@torproject.org>
Mon, 11 Feb 2013 21:27:35 +0000 (16:27 -0500)
Fixes bug 8209; bugfix on 0.2.3.1-alpha.

changes/bug8209 [new file with mode: 0644]
src/common/util.c

diff --git a/changes/bug8209 b/changes/bug8209
new file mode 100644 (file)
index 0000000..c589235
--- /dev/null
@@ -0,0 +1,6 @@
+  o Minor bugfixes:
+    - When detecting the largest possible file descriptor (in order to close
+      all file descriptors when launching a new program), actually use
+      _SC_OPEN_MAX. The old code for doing this was very, very broken.
+      Fix for bug 8209; bugfix on 0.2.3.1-alpha. Found by Coverity; this
+      is CID 743383.
index 49353a8ee10d91a9adbddd347fc7950a104bf6e4..6a69635594772911a6c063bba125eb840eb7f6d5 100644 (file)
@@ -3834,12 +3834,13 @@ tor_spawn_background(const char *const filename, const char **argv,
   child_state = CHILD_STATE_MAXFD;
 
 #ifdef _SC_OPEN_MAX
-  if (-1 != max_fd) {
+  if (-1 == max_fd) {
     max_fd = (int) sysconf(_SC_OPEN_MAX);
-    if (max_fd == -1)
+    if (max_fd == -1) {
       max_fd = DEFAULT_MAX_FD;
       log_warn(LD_GENERAL,
                "Cannot find maximum file descriptor, assuming %d", max_fd);
+    }
   }
 #else
   max_fd = DEFAULT_MAX_FD;