Skip to contentSkip to conversation

plugins: Fix resource leak in connect_socket()

PATCH In review AlexChen 2 participants 4 messages Oct 28, 2020 – Nov 6, 2020

lore
Share & tools
lore

AlexChen

author
#0 lore raw

PATCH 1/2 plugins: Fix resource leak in connect_socket()

Close the fd when connect() fails.

---
 contrib/plugins/lockstep.c | 1 +
 1 file changed, 1 insertion(+)
contrib/plugins/lockstep.c +1 -0
index a696673dff..319bd44b83 100644
@@ -292,6 +292,7 @@ static bool connect_socket(const char *path)
 
     if (connect(fd, (struct sockaddr *)&sockaddr, sizeof(sockaddr)) < 0) {
         perror("failed to connect");
+        close(fd);
         return false;
     }
 
Signature · 1 line
2.19.1
author
#1 lore raw

Kindly ping.

Quoted 20 lines · AlexChen

Close the fd when connect() fails.

---
 contrib/plugins/lockstep.c | 1 +
 1 file changed, 1 insertion(+)
contrib/plugins/lockstep.c +1 -0
index a696673dff..319bd44b83 100644
@@ -292,6 +292,7 @@ static bool connect_socket(const char *path)
 
     if (connect(fd, (struct sockaddr *)&sockaddr, sizeof(sockaddr)) < 0) {
         perror("failed to connect");
+        close(fd);
         return false;
     }
 
#2 lore raw
Quoted 1 line · AlexChen

Kindly ping.

Ahh sorry I missed these. Was there a cover letter for the series?

Quoted 22 lines · AlexChen
Quoted 20 lines

Close the fd when connect() fails.

---
 contrib/plugins/lockstep.c | 1 +
 1 file changed, 1 insertion(+)
contrib/plugins/lockstep.c +1 -0
index a696673dff..319bd44b83 100644
@@ -292,6 +292,7 @@ static bool connect_socket(const char *path)
 
     if (connect(fd, (struct sockaddr *)&sockaddr, sizeof(sockaddr)) < 0) {
         perror("failed to connect");
+        close(fd);
         return false;
     }
 
Signature · 1 line
Alex Bennée
author
#3 lore raw
Quoted 7 lines · Alex Bennée
Quoted 1 line · AlexChen

Kindly ping.

Ahh sorry I missed these. Was there a cover letter for the series?

I forgot to send the cover letter, I will send the patch V2 with the cover letter.

Thanks,
Alex Chen