summaryrefslogtreecommitdiff
path: root/debian/patches/connect_timeout_socket_leak.patch
blob: 95500a7817fcaa9d75fc03297aac94556368e8af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
--- a/libtac/lib/connect.c
+++ b/libtac/lib/connect.c
@@ -136,6 +136,7 @@
 
     /* timeout */
     if ( rc == 0 ) {
+        close(fd);
         return LIBTAC_STATUS_CONN_TIMEOUT;
     }
 
@@ -143,6 +144,7 @@
     if ( rc < 0 ) {
         TACSYSLOG((LOG_ERR,\
             "%s: connection failed with %s: %m", __FUNCTION__, ip))
+        close(fd);
         return LIBTAC_STATUS_CONN_ERR;
     }
 
@@ -151,6 +153,7 @@
     if(getpeername(fd, (struct sockaddr*)&addr, &len) == -1) {
         TACSYSLOG((LOG_ERR,\
             "%s: connection failed with %s: %m", __FUNCTION__, ip))
+        close(fd);
         return LIBTAC_STATUS_CONN_ERR;
     }
 
@@ -158,6 +161,7 @@
     if(fcntl(fd, F_SETFL, flags) == -1) {
         TACSYSLOG((LOG_ERR, "%s: cannot restore socket flags: %m",\
              __FUNCTION__)) 
+        close(fd);
         return LIBTAC_STATUS_CONN_ERR;
     }