From patchwork Fri Jan 12 05:48:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emmanuel Deloget X-Patchwork-Id: 179 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director3.mail.ord1d.rsapps.net ([172.30.191.6]) by backend31.mail.ord1d.rsapps.net (Dovecot) with LMTP id 26CGACXnWFoLSgAAgoeIoA for ; Fri, 12 Jan 2018 11:49:41 -0500 Received: from proxy12.mail.ord1d.rsapps.net ([172.30.191.6]) by director3.mail.ord1d.rsapps.net (Dovecot) with LMTP id UjQDACXnWFrrXAAAkXNnRw ; Fri, 12 Jan 2018 11:49:41 -0500 Received: from smtp7.gate.ord1d ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy12.mail.ord1d.rsapps.net (Dovecot) with LMTP id FGzfDSTnWFp3ZAAA7PHxkg ; Fri, 12 Jan 2018 11:49:41 -0500 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-Orig-To: openvpnslackdevel@openvpn.net X-Originating-Ip: [216.34.181.88] Authentication-Results: smtp7.gate.ord1d.rsapps.net; iprev=pass policy.iprev="216.34.181.88"; spf=pass smtp.mailfrom="openvpn-devel-bounces@lists.sourceforge.net" smtp.helo="lists.sourceforge.net"; dkim=fail (signature verification failed) header.d=sourceforge.net; dkim=fail (signature verification failed) header.d=sf.net; dkim=fail (signature verification failed) header.d=gmail.com; dmarc=none (p=nil; dis=none) header.from=free.fr X-Classification-ID: 94ea1cb6-f7b8-11e7-afd3-525400d28ed9-1-1 Received: from [216.34.181.88] ([216.34.181.88:47849] helo=lists.sourceforge.net) by smtp7.gate.ord1d.rsapps.net (envelope-from ) (ecelerity 4.2.1.56364 r(Core:4.2.1.14)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id AB/47-07278-427E85A5; Fri, 12 Jan 2018 11:49:40 -0500 Received: from localhost ([127.0.0.1] helo=sfs-ml-3.v29.ch3.sourceforge.com) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.89) (envelope-from ) id 1ea2Vq-0003Lu-JJ; Fri, 12 Jan 2018 16:49:02 +0000 Received: from sfi-mx-1.v28.ch3.sourceforge.com ([172.29.28.191] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1ea2Vo-0003Lh-JF for openvpn-devel@lists.sourceforge.net; Fri, 12 Jan 2018 16:49:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: 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=oLUS4YLVB8Iknv543AgWSxMFnhN5Pssfnpb2rtMM+ng=; b=W4KxeyEcuHZeIs3NUmptCENlQe ov/TZtJr5bMWPX+Eybh8WVMWj0t71orqGBdpNO61kUU+aeyk2hDQPsW6raIxh74vwDbEYqt47bH6f xTCrbEdm2IBwUFFXzbshK3/WDFTwmc7rk6cXUJm1Y/WtC2DQljo+by11SwQotvF5aS/8=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To :MIME-Version:Content-Type:Content-Transfer-Encoding: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=oLUS4YLVB8Iknv543AgWSxMFnhN5Pssfnpb2rtMM+ng=; b=Hmh7nzDTy531BhDCRjnIBTBLTT cgwj8YwLrE2AWIQ3ma3mmSadrClvavjrb/HCcXpPbC/tFvN0av1TJSIys/TzQ3usmzNPc2jhTm88i pvaHoDq/hp0+nmXLdguTZIohjVorBixwLq9u2jvS8Uz+2DCyHD5gtqPM0uXIWLKGnfvA=; Received: from mail-wm0-f66.google.com ([74.125.82.66]) by sfi-mx-1.v28.ch3.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.89) id 1ea2Vn-0001t0-Rx for openvpn-devel@lists.sourceforge.net; Fri, 12 Jan 2018 16:49:00 +0000 Received: by mail-wm0-f66.google.com with SMTP id i11so13010526wmf.4 for ; Fri, 12 Jan 2018 08:48:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=oLUS4YLVB8Iknv543AgWSxMFnhN5Pssfnpb2rtMM+ng=; b=gt7aqBddzRB4GKPhEJz5iDqhmkfqdMBOUQxrCech6dH/z89VxWHMqt6mTTbtgKtgPz sxkLpIs4YbbHyI1eA/1rPOrhwgXmPhduaMANdu/NY1Lzst6bzfVtmMP7SbYo3SLHZYA6 TX+6SQw1lNB8ZTpHMib6ZmJr0FNYcRe8YfCS9DEeWQcpM0tHZf4MtZFNE0qRxZEcUE2w R2tyJ1s8u2hCsYsNAVXuaIdLl0ReJG+6PNmMr3GvzgXFiFFoz+wQz1OrZneozMXdpweF Fl8duFtMfum+aVMstr2gawl3absTv/zUSuZTp9k/v0sT2g2/uBkFuiePA/2Ky/c/t5Rp XWcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:in-reply-to:references; bh=oLUS4YLVB8Iknv543AgWSxMFnhN5Pssfnpb2rtMM+ng=; b=bJSwzcF8cydiMupzPQn4sA67xwpx7SSH1OgHf88+fPrPNP5b1nda9iOB4ELigoLU9t XUM3D20TKHKQBtZBxjMMa1ohXsmpGQIaJetBvgwVPXdwEVazIy5Rlvx9zFWBZ/LfK600 aaygmWIJmBN4t+8ai85DIgQw3KCZBclr/R5Zri5VXLIoHFHMOFgSL0Ja1BPIdCTMMcOZ wJZYwh4Ve/61TI1hYAMPBDUTh3ya79TkGp0Z9DeDctOtXCxlJUiXUiT5gEhY1IMH3sfN +lZ8yLaqhJsQtmUfg6BBSwucEh11PawwXmMNFyvETMQA9acJHEaxgTPm9f73ntItKuZ7 c4LQ== X-Gm-Message-State: AKwxytd8652jQdnL/QhlmmuSAbR4m09r7Dvp2+6iY3Ssd/T/POvvUvjC kFnSPmwBf2UgZN6FyX6TqHbaJlRq X-Google-Smtp-Source: ACJfBotu3sIBG9iwqD/M7hEtWtIBSCI6cYuHYSEn3EUJV/oFbF20ekHrmps2n5WK8jfGiGhaz6JnoQ== X-Received: by 10.28.134.143 with SMTP id i137mr5016625wmd.2.1515775733643; Fri, 12 Jan 2018 08:48:53 -0800 (PST) Received: from edt-thinkpad.eho.intranet ([2a01:cb1c:53c:ce00:144a:841b:886c:3c9c]) by smtp.gmail.com with ESMTPSA id u5sm1606821wmf.47.2018.01.12.08.48.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 08:48:53 -0800 (PST) From: Emmanuel Deloget To: openvpn-devel@lists.sourceforge.net Date: Fri, 12 Jan 2018 17:48:24 +0100 Message-Id: X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (logout[at]free.fr) -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [74.125.82.66 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (emmanueldeloget53[at]gmail.com) 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-Headers-End: 1ea2Vn-0001t0-Rx Subject: [Openvpn-devel] [PATCH 1/3] OpenSSL: check EVP_PKEY key types before returning the pkey 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: , MIME-Version: 1.0 Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox The internal EVP_PKEY::pkey member is an union thus we need to check for the real key type before we can return the corresponding RSA, DSA or EC public key. Reported-by: Selva Nair Signed-off-by: Emmanuel Deloget Acked-by: Steffan Karger diff --git a/src/openvpn/openssl_compat.h b/src/openvpn/openssl_compat.h index 70b19aea..8b29cdaf 100644 --- a/src/openvpn/openssl_compat.h +++ b/src/openvpn/openssl_compat.h @@ -240,7 +240,7 @@ X509_OBJECT_get_type(const X509_OBJECT *obj) static inline RSA * EVP_PKEY_get0_RSA(EVP_PKEY *pkey) { - return pkey ? pkey->pkey.rsa : NULL; + return (pkey && pkey->type == EVP_PKEY_RSA) ? pkey->pkey.rsa : NULL; } #endif @@ -254,7 +254,7 @@ EVP_PKEY_get0_RSA(EVP_PKEY *pkey) static inline EC_KEY * EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey) { - return pkey ? pkey->pkey.ec : NULL; + return (pkey && pkey->type == EVP_PKEY_EC) ? pkey->pkey.ec : NULL; } #endif @@ -282,7 +282,7 @@ EVP_PKEY_id(const EVP_PKEY *pkey) static inline DSA * EVP_PKEY_get0_DSA(EVP_PKEY *pkey) { - return pkey ? pkey->pkey.dsa : NULL; + return (pkey && pkey->type == EVP_PKEY_DSA) ? pkey->pkey.dsa : NULL; } #endif