* Anytime a socket connect() fails, CLOSE THE SOCKET before erroring out.
authorArt Cancro <ajc@citadel.org>
Sat, 26 Apr 2003 21:55:15 +0000 (21:55 +0000)
committerArt Cancro <ajc@citadel.org>
Sat, 26 Apr 2003 21:55:15 +0000 (21:55 +0000)
  Not doing so causes a file descriptor leak.

citadel/ChangeLog
citadel/citadel_ipc.c
citadel/citmail.c
citadel/clientsocket.c

index f2edb0be7c1ecc56f1fb9d723bbb086614ef25c6..9485bc4b7a0f56691824033436f0215b4c28f669 100644 (file)
@@ -1,4 +1,8 @@
  $Log$
+ Revision 605.39  2003/04/26 21:55:15  ajc
+ * Anytime a socket connect() fails, CLOSE THE SOCKET before erroring out.
+   Not doing so causes a file descriptor leak.
+
  Revision 605.38  2003/04/26 04:22:51  ajc
  * Removal of individual "remote" lines from message delivery instruction sets
    was corrupting the end of the set, rendering the "bounceto" line unusable
@@ -4646,3 +4650,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
+
index c4feabae6085761240c62f64337fcaa1385f1b4a..921e7d63b47ebbd7597d8694f4afb6ca2e55085e 100644 (file)
@@ -2487,6 +2487,7 @@ static int connectsock(char *host, char *service, char *protocol, int defaultPor
        }
 
        if (connect(s, (struct sockaddr *) &sin, sizeof(sin)) < 0) {
+               close(s);
                return -1;
        }
 
@@ -2508,6 +2509,7 @@ static int uds_connectsock(int *isLocal, char *sockpath)
        }
 
        if (connect(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
+               close(s);
                return -1;
        }
 
index cadb6b25ebb0f52f7a870ae206628958f6ce4668..00e6f9165d4d2213d2dcc6c5f1c172cee9363a5b 100644 (file)
@@ -65,6 +65,7 @@ int uds_connectsock(char *sockpath)
        if (connect(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
                fprintf(stderr, "can't connect: %s\n",
                        strerror(errno));
+               close(s);
                exit(3);
        }
 
index 24aa21e6b974ef520a9cb3ffe17222017d62f652..5ea001912ac3ff37d26b770e67da7185ac85ed99 100644 (file)
@@ -87,6 +87,7 @@ int sock_connect(char *host, char *service, char *protocol)
        if (connect(s, (struct sockaddr *) &sin, sizeof(sin)) < 0) {
                lprintf(3, "can't connect to %s:%s: %s\n",
                        host, service, strerror(errno));
+               close(s);
                return(-1);
        }