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 localhost.localdomain (unknown [138.197.159.143]) by gnuweeb.org (Postfix) with ESMTPSA id 79F417E585; Fri, 27 May 2022 00:02:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1653609759; bh=BJ0NBpWcgvrUwzD3MBtXLzsNJZXs3MCmqn+/xN+97TQ=; h=From:To:Cc:Subject:Date:From; b=pW4eHlQfvodp+jNIDV1CYcyE5X2ZGGZ9eRIKnzsLmmEhCh4TYrHgSocl0OARj8LLW 33yIwDKi222e2glA26wQoMnYJE8/AZzThnPQHFVqxlRxi3YFBK1W2OqfbWUCcKP6om XKgREvwPv65blk8SkRsuXnR8gic0+iYuql8Eewag3Tggwh+zRAz2EYPr75V+s24MSD e0UaXTUlXH3kOKOlE1aXOkUkj+d33yeohYT1GyRKMLhlaUtI7/OsPNnneInzfBFBou 2Jlg4ai2TL/ZDNGo/Sq9YLrOmWxRybGfcnqYbBouvxs4A/Lp4sMEy40F54AOW/7E6Y SYpIU5j/yCXcw== From: Alviro Iskandar Setiawan To: Ammar Faizi Cc: Alviro Iskandar Setiawan , GNU/Weeb Mailing List , Tea Inside Mailing List , Ammar Faizi , Louvian Lyndal , Michael Arminto Subject: [PATCH teavpn2 0/3] teavpn2 fixes Date: Fri, 27 May 2022 00:02:24 +0000 Message-Id: <20220527000227.1253934-1-alviro.iskandar@gnuweeb.org> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Hi all, I have a few TeaVPN2 fixes, please review. 3 patches below: ### Patch 1 The calloc() function from libc sets the @errno variable to ENOMEM when overflow, not to EOVERFLOW. Change it to ENOMEM to follow libc error code. ### Patch 2 The malloc() call in escapeshellarg() doesn't have a NULL check. This results in a potential NULL pointer dereference. Fix this by checking the return value of malloc(). Just return NULL directly if we hit the ENOMEM case. ### Patch 3 The libc syscall wrappers mostly return -1 when they fail, then they set the error code to the @errno variable. The current code seems to be doing something wrong. We assume it errors when the return value is negative. However, not all negative values are meant to be an error indicator. On Linux, the only reserved error code is within range [-4095, -1]. That means we still have a potential to get a negative return value that is not an error. I understand that most of them work fine here because of the nature of the syscall itself that won't return a negative value upen succcessful. But the above assumption about the negative value is not correct. Replace the error checking from (ret < 0) to (ret == -1) to reflect the above fact. Cc: Ammar Faizi Cc: Louvian Lyndal Cc: Michael Arminto Signed-off-by: Alviro Iskandar Setiawan --- Alviro Iskandar Setiawan (3): allocator: Fix `@errno` value when overflow net: iface: Fix a potential NULL pointer dereference arch/linux: syscall: Fix retval checking in libc syscall src/teavpn2/allocator.c | 2 +- src/teavpn2/arch/generic/linux.h | 12 ++++++------ src/teavpn2/net/linux/iface.c | 7 +++++-- 3 files changed, 12 insertions(+), 9 deletions(-) base-commit: 5e5223089d02c6fde68a0b567ca802317be59467 prerequisite-patch-id: b71545410b349281e6ead6ff1dcc1f71f8ab30a4 prerequisite-patch-id: 7fe15b03300490b8aa25cac4dd0be0bd3ce7a4bb -- Alviro Iskandar Setiawan