public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH] slc: Fix file descriptor leak
@ 2022-06-06  2:27 Ammar Faizi
  2022-06-06  2:28 ` Ammar Faizi
  2022-06-06  2:54 ` Alviro Iskandar Setiawan
  0 siblings, 2 replies; 10+ messages in thread
From: Ammar Faizi @ 2022-06-06  2:27 UTC (permalink / raw)
  To: Arthur Lapz; +Cc: GNU/Weeb Mailing List, Ammar Faizi

Arthur Lapz reported that he is seeing a blocking socket from the
public client side after the app side has closed the connection.

This turned out that we haven't closed the SLC socket file descriptor:

```
     Isolated                              Server
     --------                              ------

      fd_app --                         -- fd_public_client
               |----[ SLC circuit ]----|
  fd_circuit --                         -- fd_circuit

```
After the app in the isolated client has closed its fd, we didn't close
the fd_app and fd_circuit. That's why the server is still sleeping,
waiting for any response from the isolated area.

This was just a typo in if statements that caused the close() paths were
not taken. Simply fix the typo. Change "==" to "!=".

Link: https://t.me/lostcontrol_s1/16737
Link: https://t.me/lostcontrol_s1/16739 # Reproducer
Fixes: 04a86adffa415e8365d27929bbb826028e00bfd3 ("Initial commit")
Reported-by: Arthur Lapz <[email protected]>
Signed-off-by: Ammar Faizi <[email protected]>
---
 slc.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/slc.cpp b/slc.cpp
index bd836cb..5fcdd93 100644
--- a/slc.cpp
+++ b/slc.cpp
@@ -600,9 +600,9 @@ out_free:
 
 	socket_bridge(fd_pa, fd_pb);
 out:
-	if (fd_pa == -1)
+	if (fd_pa != -1)
 		close(fd_pa);
-	if (fd_pb == -1)
+	if (fd_pb != -1)
 		close(fd_pb);
 	return NULL;
 }
-- 
Ammar Faizi

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-06-06  3:02 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-06  2:27 [PATCH] slc: Fix file descriptor leak Ammar Faizi
2022-06-06  2:28 ` Ammar Faizi
2022-06-06  2:42   ` Arthur Lapz
2022-06-06  2:46     ` Ammar Faizi
2022-06-06  2:51       ` Ammar Faizi
2022-06-06  2:56         ` Arthur Lapz
2022-06-06  2:57           ` Ammar Faizi
2022-06-06  2:59             ` Arthur Lapz
2022-06-06  2:54 ` Alviro Iskandar Setiawan
2022-06-06  3:02   ` Ammar Faizi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox