From patchwork Wed Mar 24 11:23:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arne Schwabe X-Patchwork-Id: 1654 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director15.mail.ord1d.rsapps.net ([172.27.255.7]) by backend30.mail.ord1d.rsapps.net with LMTP id uP8pIxS8W2A0bQAAIUCqbw (envelope-from ) for ; Wed, 24 Mar 2021 18:24:20 -0400 Received: from proxy3.mail.iad3a.rsapps.net ([172.27.255.7]) by director15.mail.ord1d.rsapps.net with LMTP id qDIbIxS8W2DwZQAAIcMcQg (envelope-from ) for ; Wed, 24 Mar 2021 18:24:20 -0400 Received: from smtp25.gate.iad3a ([172.27.255.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy3.mail.iad3a.rsapps.net with LMTPS id YJ8gHBS8W2BzGQAAYaqY3Q (envelope-from ) for ; Wed, 24 Mar 2021 18:24:20 -0400 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.105.38.7] Authentication-Results: smtp25.gate.iad3a.rsapps.net; iprev=pass policy.iprev="216.105.38.7"; 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; dmarc=none (p=nil; dis=none) header.from=rfc2549.org X-Suspicious-Flag: YES X-Classification-ID: aca80fdc-8cef-11eb-887a-52540086a678-1-1 Received: from [216.105.38.7] ([216.105.38.7:54988] helo=lists.sourceforge.net) by smtp25.gate.iad3a.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 22/5A-04167-31CBB506; Wed, 24 Mar 2021 18:24:19 -0400 Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.92.3) (envelope-from ) id 1lPBuf-00006t-EH; Wed, 24 Mar 2021 22:23:41 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.3) (envelope-from ) id 1lPBud-00006j-6X for openvpn-devel@lists.sourceforge.net; Wed, 24 Mar 2021 22:23:39 +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:To: From:Sender:Reply-To:Cc: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=ff63qpyy6tE9UmmGVrNVBnDo1eiNQZ/H+9sAKXpgkj0=; b=HQ4FIDqWHchYaYUZCqkVRGGhuh YrwDca3MEP3XK3NGH641qeYuuM+IsBCvCkCUaGehfBKjX6/Qn/tGD3x8tl0qpRiR0n1ivQpvx6MDQ mv12+JXfue/rv0XfZ7s1UInY9ojve5GnshgtzvjiIn93DFnhdfVAjrSHAQOqOQhvCSrI=; 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:To:From:Sender:Reply-To:Cc :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=ff63qpyy6tE9UmmGVrNVBnDo1eiNQZ/H+9sAKXpgkj0=; b=gOV8L9vurv0Q32oxYl6BseqOm4 90RFi+kmq/6XtirfECb+jSf3urvixkKrE/senEa9X3Q2gsk420Z3aRtt8ItNSeDCDUFmgCEXGUWbv YxW/KuswBDF5xHd8t65JnPoBe6D0HmiRTCE3K7SqrxObGQZjGyf18DZMxrbC7R7P0G38=; Received: from mail.blinkt.de ([192.26.174.232]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.3) id 1lPBub-0003Yk-HB for openvpn-devel@lists.sourceforge.net; Wed, 24 Mar 2021 22:23:39 +0000 Received: from kamera.blinkt.de ([2001:638:502:390:20c:29ff:fec8:535c]) by mail.blinkt.de with smtp (Exim 4.94 (FreeBSD)) (envelope-from ) id 1lPBuV-000ExO-8o for openvpn-devel@lists.sourceforge.net; Wed, 24 Mar 2021 23:23:31 +0100 Received: (nullmailer pid 520 invoked by uid 10006); Wed, 24 Mar 2021 22:23:31 -0000 From: Arne Schwabe To: openvpn-devel@lists.sourceforge.net Date: Wed, 24 Mar 2021 23:23:30 +0100 Message-Id: <20210324222330.455-4-arne@rfc2549.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210324222330.455-1-arne@rfc2549.org> References: <20210324222330.455-1-arne@rfc2549.org> X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [URIs: rfc2549.org] 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-Headers-End: 1lPBub-0003Yk-HB Subject: [Openvpn-devel] [PATCH 4/4] Use correct types for OpenSSL and Windows APIs 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 error code of OpenSSL is a long. On most Unics systems (mac, Linux...) this happens to be the same as size_t. But on Windows as LP64, long is a 32 bit type and size_t is a 64 bit type. So use the same type as OpenSSL. When calling the Windows API use DWORD for the functions that want a DWORD. Signed-off-by: Arne Schwabe Acked-by: Gert Doering --- src/openvpn/crypto_openssl.c | 2 +- src/openvpn/cryptoapi.c | 2 +- src/openvpn/route.c | 9 +++------ 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/openvpn/crypto_openssl.c b/src/openvpn/crypto_openssl.c index 4486d246..573beaed 100644 --- a/src/openvpn/crypto_openssl.c +++ b/src/openvpn/crypto_openssl.c @@ -199,7 +199,7 @@ crypto_clear_error(void) void crypto_print_openssl_errors(const unsigned int flags) { - size_t err = 0; + unsigned long err = 0; while ((err = ERR_get_error())) { diff --git a/src/openvpn/cryptoapi.c b/src/openvpn/cryptoapi.c index a992441b..ded8c914 100644 --- a/src/openvpn/cryptoapi.c +++ b/src/openvpn/cryptoapi.c @@ -997,7 +997,7 @@ pkey_rsa_sign(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, } msg(D_LOW, "cryptoapicert: calling priv_enc_CNG with alg = %ls", alg); - *siglen = priv_enc_CNG(cd, alg, tbs, (int)tbslen, sig, *siglen, + *siglen = priv_enc_CNG(cd, alg, tbs, (int)tbslen, sig, (int)*siglen, cng_padding_type(padding), (DWORD)saltlen); return (*siglen == 0) ? 0 : 1; diff --git a/src/openvpn/route.c b/src/openvpn/route.c index 5e1dca67..c6b3dc58 100644 --- a/src/openvpn/route.c +++ b/src/openvpn/route.c @@ -2701,12 +2701,11 @@ get_default_gateway_row(const MIB_IPFORWARDTABLE *routes) struct gc_arena gc = gc_new(); DWORD lowest_metric = MAXDWORD; const MIB_IPFORWARDROW *ret = NULL; - int i; int best = -1; if (routes) { - for (i = 0; i < routes->dwNumEntries; ++i) + for (DWORD i = 0; i < routes->dwNumEntries; ++i) { const MIB_IPFORWARDROW *row = &routes->table[i]; const in_addr_t net = ntohl(row->dwForwardDest); @@ -3167,14 +3166,13 @@ void show_routes(int msglev) { struct gc_arena gc = gc_new(); - int i; const MIB_IPFORWARDTABLE *rt = get_windows_routing_table(&gc); msg(msglev, "SYSTEM ROUTING TABLE"); if (rt) { - for (i = 0; i < rt->dwNumEntries; ++i) + for (DWORD i = 0; i < rt->dwNumEntries; ++i) { msg(msglev, "%s", format_route_entry(&rt->table[i], &gc)); } @@ -4023,8 +4021,7 @@ test_local_addr(const in_addr_t addr, const struct route_gateway_info *rgi) const MIB_IPFORWARDTABLE *rt = get_windows_routing_table(&gc); if (rt) { - int i; - for (i = 0; i < rt->dwNumEntries; ++i) + for (DWORD i = 0; i < rt->dwNumEntries; ++i) { const MIB_IPFORWARDROW *row = &rt->table[i]; const in_addr_t net = ntohl(row->dwForwardDest);