From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NO_DNS_FOR_FROM,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 Received: from integral2.. (unknown [36.73.79.120]) by gnuweeb.org (Postfix) with ESMTPSA id 981D57ED7E; Mon, 6 Jun 2022 02:27:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1654482476; bh=C41qBh/nA1xOlhHJcbI7C+Inmv/5guRv/65XZ/N/7Ak=; h=From:To:Cc:Subject:Date:From; b=fW1fhE2hQKWC7h8owUVLO/60NqaOLwYAlDwe4pyfJAIMzbVqwyIjxXT3txfoc6TEh ZS234fdHIVNPsjVH25JNMQEj/FmFyYNhqt54RsLD2Ps95PLPLYXhkZcd9wdsCDfftK YjvZ0dNPGPG97TYlwCi5M4qtquWqn1EYlFGH/0qB9thif7n0sVI1TtC55bXQuz8qAV hOvYz9P8fFE1MpdZvGHpbEk4bWiNkDcbewAYIjEx4jeIWfOUWIcns8a3l2/L9xTX3A +HSNuW5AQC+22FrH1TnDPpZPomPuTuOO8Pe+NqfNUvS/WfcCTiDZ6yODd3azLVshzk sAXO+/UD4ATFQ== From: Ammar Faizi To: Arthur Lapz Cc: GNU/Weeb Mailing List , Ammar Faizi Subject: [PATCH] slc: Fix file descriptor leak Date: Mon, 6 Jun 2022 09:27:47 +0700 Message-Id: <20220606022747.316158-1-ammarfaizi2@gnuweeb.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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 Signed-off-by: Ammar Faizi --- 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