From patchwork Mon Mar 25 07:14:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 3666 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:c315:b0:55c:c090:46f0 with SMTP id jk21csp2272375mab; Mon, 25 Mar 2024 00:15:22 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUM2PY9fTLf5wKRm5HY1xxiBgyW7mC+FWoONtZSDwYftcXjA/HUjUYo/BpSsjb7cByNyR1RxeFiXV+znwFtzBcQlVM6Cz0= X-Google-Smtp-Source: AGHT+IGNeWjUCPbSAwyfwukdaRjCblqa4L3SPgsZqlIJ3IRlF3MOdDEsN1Mxl9p7jOlKQtvHAWk1 X-Received: by 2002:a17:902:8a83:b0:1dc:df03:ad86 with SMTP id p3-20020a1709028a8300b001dcdf03ad86mr7169130plo.2.1711350922097; Mon, 25 Mar 2024 00:15:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1711350922; cv=none; d=google.com; s=arc-20160816; b=AD3zljfUk+RKPJfI3a0uQpvD+eTQqyu0Gak20oIkm6NS4k3G4vKUupxvMpo4VEFeka +AmbCu4R2fqZ3l4hhRVGBYLQZ/TD1BXNZGXZYwyHB9Hx10PxFDyorZs4BImBbuvYzzlb Knmtq6HuATUyrlhZmekrrAVK7blL+QlLWdPhRhKNZWfwy7EowZoUzi7ooa3R3G6TdPdL chFwMs48W29FAnJjrWw/WxU5aD6MMeHjvNas05gY/GXcmvJRKBOt+rY752nQ+cJ/X7vp QZhJ+n7gCw2yB0BrQQ6wUSKs9pgDWQCf0JnrXTwd33/IdCgaQOyafdmDJP6NF3mzDQGV sGaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:dkim-signature; bh=fLLXwwd1D0/8/xjgl+6UkUFwTEpTBcmywAe+DRCds+g=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=g/7buaFZCoNuVqFJp6twcKeF8tY2d8W7aC9ehYXHd2RSdBG/ghGsv9R7fYWiDUuBN8 zyCbjWXtPs0G7/Va5P3sRyIbJdGktWLEk6KINOiEkDMLO38JJVFHgLgB5JCPA3jdMME2 EOee3WNrbIhWnrSG0KsIJD2B9yIgZC//mwerl5NuIZWaEJ7g5XDga/g1rJkxkIkNLO72 yrgv6kQsCc1x5AsdFElLsRScqLRqQLsP6Xn9szXIf7kroMjDjsJfN1ygKfShREpzRfSE Bi+FwtpDIKnKz+espVKw9j18m+m8SGw4/c0LxcUtslShESCm82EV+5iWJIaJ3mjwppkD 2ciA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=LYFRZJKW; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=Eu30waqi; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id h10-20020a170902f54a00b001ddbde8f59bsi4546608plf.582.2024.03.25.00.15.21 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Mar 2024 00:15:22 -0700 (PDT) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=LYFRZJKW; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=Eu30waqi; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1roeXw-0007RV-II; Mon, 25 Mar 2024 07:15:04 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1roeXt-0007RC-KG for openvpn-devel@lists.sourceforge.net; Mon, 25 Mar 2024 07:15:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=jq/Ur8XIVjLiH71l16TeJiSamFpo2kuw4IQgLHpbtOc=; b=LYFRZJKWh/KfEWK16Yjp/FPSwE jJ3F2IvRsEEtnKCm7dVZGFTxS07X6oSGgvtghdgjdPNtEeOLtWScCjmbCjt5NLYbXNkwLCzE043+N MbfMPFz58ayuhLWHDdfj/J0opcD9OJc7T0GUvWL6QsWZxESpVehXUTgvpo5cIVzyZU9c=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=jq/Ur8XIVjLiH71l16TeJiSamFpo2kuw4IQgLHpbtOc=; b=Eu30waqifbOAx40CXuSoBdS66W 0nwnxhyiRQV0wkHpNV4AU/6MKTAr8FekQsdJnwsa1UAEj1gig5OJZuJ8OuOBgiPiWp4XVPVVFDJxu 8jocDvTP6yTYvIPIgS7Bq+i6gSWengjyzTqNE6G7wUs83lTWa3J3q90qUXdXpnCK+Beg=; Received: from dhcp-174.greenie.muc.de ([193.149.48.174] helo=blue.greenie.muc.de) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1roeXs-0000eg-QE for openvpn-devel@lists.sourceforge.net; Mon, 25 Mar 2024 07:15:01 +0000 Received: from blue.greenie.muc.de (localhost [127.0.0.1]) by blue.greenie.muc.de (8.17.1.9/8.17.1.9) with ESMTP id 42P7EnHX012195 for ; Mon, 25 Mar 2024 08:14:49 +0100 Received: (from gert@localhost) by blue.greenie.muc.de (8.17.1.9/8.17.1.9/Submit) id 42P7Enq0012194 for openvpn-devel@lists.sourceforge.net; Mon, 25 Mar 2024 08:14:49 +0100 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Mon, 25 Mar 2024 08:14:48 +0100 Message-ID: <20240325071448.12143-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.43.2 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Score: -0.0 (/) X-Spam-Report: Spam detection software, running on the system "util-spamd-2.v13.lw.sourceforge.com", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Frank Lichtenheld As Coverity says: Either the check against null is unnecessary, or there may be a null pointer dereference. In phase2_tcp_server: Pointer is checked against null but then dereferenced anyway Content analysis details: (-0.0 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record X-Headers-End: 1roeXs-0000eg-QE Subject: [Openvpn-devel] [PATCH v2] phase2_tcp_server: fix Coverity issue "Dereference after null check" X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1794481504298621533?= X-GMAIL-MSGID: =?utf-8?q?1794481504298621533?= From: Frank Lichtenheld As Coverity says: Either the check against null is unnecessary, or there may be a null pointer dereference. In phase2_tcp_server: Pointer is checked against null but then dereferenced anyway There is only one caller (link_socket_init_phase2) and it already has an ASSERT(sig_info). So use that here was well. v2: - fix cleanly by actually asserting that sig_info is defined Change-Id: I8ef199463d46303129a3f563fd9eace780a58b8a Signed-off-by: Frank Lichtenheld Acked-by: Arne Schwabe --- This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master. Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/490 This mail reflects revision 2 of this Change. Acked-by according to Gerrit (reflected above): Arne Schwabe diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c index 480f4e5..387cb40 100644 --- a/src/openvpn/socket.c +++ b/src/openvpn/socket.c @@ -2005,7 +2005,8 @@ phase2_tcp_server(struct link_socket *sock, const char *remote_dynamic, struct signal_info *sig_info) { - volatile int *signal_received = sig_info ? &sig_info->signal_received : NULL; + ASSERT(sig_info); + volatile int *signal_received = &sig_info->signal_received; switch (sock->mode) { case LS_MODE_DEFAULT: @@ -2031,7 +2032,7 @@ false); if (!socket_defined(sock->sd)) { - register_signal(sig_info, SIGTERM, "socket-undefiled"); + register_signal(sig_info, SIGTERM, "socket-undefined"); return; } tcp_connection_established(&sock->info.lsa->actual);