Imported Upstream version 2.4.5p1
[debian/amanda] / server-src / amindexd.c
index e35d2709fe2ed89c4108cec033778f2e464f4fc3..7ad24e871941771e3da41b7fb987f9457607afc4 100644 (file)
@@ -24,7 +24,7 @@
  * file named AUTHORS, in the root directory of this distribution.
  */
 /*
- * $Id: amindexd.c,v 1.39.2.11.4.4.2.13.2.1 2004/04/05 17:22:59 martinea Exp $
+ * $Id: amindexd.c,v 1.39.2.11.4.4.2.13.2.3 2005/10/02 13:48:42 martinea Exp $
  *
  * This is the server daemon part of the index client/server system.
  * It is assumed that this is launched from inetd instead of being
@@ -798,27 +798,17 @@ char **argv;
     char *s, *fp;
     int ch;
     char *cmd_undo, cmd_undo_ch;
-    int i;
+    socklen_t socklen;
     struct sockaddr_in his_addr;
     struct hostent *his_name;
     char *arg;
     char *cmd;
     int len;
-    int fd;
     int user_validated = 0;
     char *errstr = NULL;
     char *pgm = "amindexd";                    /* in case argv[0] is not set */
 
-    for(fd = 3; fd < FD_SETSIZE; fd++) {
-       /*
-        * Make sure nobody spoofs us with a lot of extra open files
-        * that would cause an open we do to get a very high file
-        * descriptor, which in turn might be used as an index into
-        * an array (e.g. an fd_set).
-        */
-       close(fd);
-    }
-
+    safe_fd(-1, 0);
     safe_cd();
 
     /*
@@ -913,8 +903,8 @@ char **argv;
               (char *)his_name->h_addr_list[0], his_name->h_length);
     } else {
        /* who are we talking to? */
-       i = sizeof (his_addr);
-       if (getpeername(0, (struct sockaddr *)&his_addr, &i) == -1)
+       socklen = sizeof (his_addr);
+       if (getpeername(0, (struct sockaddr *)&his_addr, &socklen) == -1)
            error("getpeername: %s", strerror(errno));
     }
     if (his_addr.sin_family != AF_INET || ntohs(his_addr.sin_port) == 20)