From patchwork Tue May 16 02:42:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Selva Nair X-Patchwork-Id: 3217 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7300:7b9a:b0:c3:1364:a2a2 with SMTP id j26csp190947dyk; Mon, 15 May 2023 19:57:22 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4bXA83oDITZ05oGJxyeA/OyvlsphGeIRVYFyQ9vCrZmAgJ5mK7fOG1UbsgabTUze3PB11V X-Received: by 2002:a92:cf49:0:b0:333:eb18:2b72 with SMTP id c9-20020a92cf49000000b00333eb182b72mr20414317ilr.25.1684205842572; Mon, 15 May 2023 19:57:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684205842; cv=none; d=google.com; s=arc-20160816; b=Q+X1QWDuS5R3S8vP5XeY+CRLkZTLnm3kuFKjRmPqaeBDrnZr03Qss17BlnLgJfT1Bt bSEfzjoGe6fuSH6w57VPRSRKQ/34rKhR6TqQt9UMwtBC/esFtVqpJo9P27ntc8P/CARP ZW8lnLujYnfYH/sCjPUtLK22CNdt9lxiYM+PvkB4Uwz4ygm5gZGO9C81398gSVslJN3I kUccCqR6hpvjtM8TmFTtDqNiQQdfg0FPQh/pHTx1vpAFpfmB/gOA6qGCnH9D6s/LqZjX bmn/Jid8lPTubpSPF4IQn/4XpFp0GW0ZKjq1sMuB/XikgvZDKwb4SK2rBEiUywIGa7XN inYA== 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:message-id:date:to:from:dkim-signature:dkim-signature :dkim-signature; bh=ZxdPvRQOe3OYpCt+WmorpT3z5TD31Y181l3Z1BqCm9E=; b=pmcLilS2RAiZY0Ayxyff7vMXxlsTfyvegrL71+Am+MvCrg/apdeoyEXZVIsbgQb9aG Vt8ncx8HLvIbZByka3awYLlTkpi3mwRjtstPXDRUJOQXh0K5rCTH00daxQNSiRAZrh1p /vy7PeUx72m+suA/XdrL/JNOOAFRaFX1TXFSSvdiXl6k1//YT46RpIQqUf7L7SiicSQg JBPtbl69G9qcHlQKJVKscETyWGiFc/S+dTM3yOGPkpjTHCZ4xdfuxo6mz9EmTx5ssoAN swR9JkCYObsk3eE9SOdpxnkfaatQwLC/ZxGlreBt/PEOimrxU7di8QK3GzaUJeDiKB1F 2jfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=NdIIaLT1; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b="Oinq43x/"; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=cRMxljg6; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id h21-20020a02b615000000b00414267b9e9bsi11613046jam.88.2023.05.15.19.57.21 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 May 2023 19:57: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=NdIIaLT1; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b="Oinq43x/"; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=cRMxljg6; 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=QUARANTINE dis=NONE) header.from=gmail.com 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 1pykru-0002ic-Pu; Tue, 16 May 2023 02:56:55 +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 1pykrt-0002iR-9W for openvpn-devel@lists.sourceforge.net; Tue, 16 May 2023 02:56:54 +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:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=MHLGzx+Pwgq43Xa8mk/YS1ovU10sLhyZBvhdMjFTeAY=; b=NdIIaLT1N6SxsScDa+4Gc1FWTL FQJX0wKZRE0OEUuFKme1WOchBGSF7V3a0dV2w2nyE8/FlHexn9+Wmpd117Mnvep7iufxKLLGS7DAn vPVirxtCYuRaZ3Iqt8Tyc7/tm2Pad8WD2X9l80tA1EUqNyrdIHXJXPRzoCp2TjOe3U/Q=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject:Cc:To:From :Sender:Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=MHLGzx+Pwgq43Xa8mk/YS1ovU10sLhyZBvhdMjFTeAY=; b=O inq43x/AUhVRX5LOyU4Cxa0UABocYFQjDi90mttEf1Yfx8P24uW0jSfHBzOm3Lcy+pC6QPTGBF84S OpHxB0FBvb4uT83EO+gB7b5UTCd9/ce1E2ZCZjZnrhDup1a63qyiL662NB3icC9SnM6y+UHdtZ92p g0FElrSi5UGMuF9E=; Received: from mail-yw1-f171.google.com ([209.85.128.171]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1pykrq-0092IK-N2 for openvpn-devel@lists.sourceforge.net; Tue, 16 May 2023 02:56:54 +0000 Received: by mail-yw1-f171.google.com with SMTP id 00721157ae682-55a1c5976d0so15129627b3.1 for ; Mon, 15 May 2023 19:56:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684205805; x=1686797805; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=MHLGzx+Pwgq43Xa8mk/YS1ovU10sLhyZBvhdMjFTeAY=; b=cRMxljg6LfYAyos4l+UsXCM2P4p277xcSaT/JbBHB2IwT5W8HZzN723E1bXRxBZd3W SVRuwOPerD7DAHFKKoRsj8U7Scjkpq1y29LiE0WwLqUFjolx+5fDr35p3Ri6h8JMYmd7 bSvyjRDL4p/W++yXQb8pBgZk9FQLrO5WgsirYUj99lie3ahFh0ASeUKJoGNWSTKzAmzX SBYpEqumqtilUIW+Gd+Iwgn7Xu2NBJgE+tZUJKCg+49GTaDWX5G746FJRzEWweJfNoBk 4dQ5pRnwMp5AM+OwVHkxcButUd4bQUaesjNvoMRV3feNmvSOTc9Dqb4602ISmeklEzrK KyKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684205805; x=1686797805; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=MHLGzx+Pwgq43Xa8mk/YS1ovU10sLhyZBvhdMjFTeAY=; b=ekgGuRn1eteZYT559yrqhJADaXWoPVyNB8ywRJ52Ofj5bQugusGPEsK8AipqrdkEvZ v7vmKHAHjttvBd1mhbMOhmJGXTwh989tpYla7mIEjXS/8XerQETiXP5QB2Zs8VNc5cD9 5KfrQjS3jIRb/R9PI7kOnK7g8xVePXCOvKW31RzyEf2yultKWQ/964sf1MonWCdZjxfN mgZoixJ0ecbQFXOVks8UFBr7heypWQKas56QMBhB5d3OAuXUsv3B1FChhQFvFzn9OMua eUAxeU6mD9Fknz3uNU+erkyjQZErWKRYmpBZtF2+LdfqYW8EoF2Q4xO9EZ2UR0LIocvL jFxQ== X-Gm-Message-State: AC+VfDwB3IK16LdBG0aqxSGY04Qwz7AUmp5UJBiDmROoQfR6FsofA6ot 2BpHSRYojynDIOg1pbdoi6K3pdNXPj4= X-Received: by 2002:a25:ae90:0:b0:b9d:863e:2a61 with SMTP id b16-20020a25ae90000000b00b9d863e2a61mr989116ybj.0.1684205804702; Mon, 15 May 2023 19:56:44 -0700 (PDT) Received: from uranus.sansel.ca (bras-vprn-tnhlon4053w-lp130-01-70-51-222-24.dsl.bell.ca. [70.51.222.24]) by smtp.gmail.com with ESMTPSA id p64-20020a0dcd43000000b00559f1cb8444sm284637ywd.70.2023.05.15.19.56.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 May 2023 19:56:44 -0700 (PDT) From: selva.nair@gmail.com To: openvpn-devel@lists.sourceforge.net Date: Mon, 15 May 2023 22:42:32 -0400 Message-Id: <20230516024232.2680491-1-selva.nair@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Score: -0.2 (/) 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: Selva Nair Currently we use the ANSI version of CreateEvent causing name of the exit event to be interpreted differently depending on the code page in effect. Internally all strings parsed from command line and [...] Content analysis details: (-0.2 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.128.171 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [selva.nair[at]gmail.com] -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.128.171 listed in wl.mailspike.net] -0.0 T_SCC_BODY_TEXT_LINE No description available. X-Headers-End: 1pykrq-0092IK-N2 Subject: [Openvpn-devel] [PATCH] Correctly handle Unicode names for exit event 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?1766017825577156243?= X-GMAIL-MSGID: =?utf-8?q?1766017825577156243?= From: Selva Nair Currently we use the ANSI version of CreateEvent causing name of the exit event to be interpreted differently depending on the code page in effect. Internally all strings parsed from command line and config file are stored as UTF8-encoded Uniode. When passed to Windows API calls, these should be converted to UTF16 and wide character version of the API should be used. CreateEvent calls for unnamed events are left unchanged as there is no text-encoding dependence in those cases. Signed-off-by: Selva Nair Acked-by: Lev Stipakov --- src/openvpn/win32.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/openvpn/win32.c b/src/openvpn/win32.c index 1ae3723f..25da54ab 100644 --- a/src/openvpn/win32.c +++ b/src/openvpn/win32.c @@ -509,19 +509,19 @@ win32_signal_open(struct win32_signal *ws, && !HANDLE_DEFINED(ws->in.read) && exit_event_name) { struct security_attributes sa; + struct gc_arena gc = gc_new(); + const wchar_t *exit_event_nameW = wide_string(exit_event_name, &gc); if (!init_security_attributes_allow_all(&sa)) { msg(M_ERR, "Error: win32_signal_open: init SA failed"); } - ws->in.read = CreateEvent(&sa.sa, - TRUE, - exit_event_initial_state ? TRUE : FALSE, - exit_event_name); + ws->in.read = CreateEventW(&sa.sa, TRUE, exit_event_initial_state ? TRUE : FALSE, + exit_event_nameW); if (ws->in.read == NULL) { - msg(M_WARN|M_ERRNO, "NOTE: CreateEvent '%s' failed", exit_event_name); + msg(M_WARN|M_ERRNO, "NOTE: CreateEventW '%s' failed", exit_event_name); } else { @@ -534,6 +534,7 @@ win32_signal_open(struct win32_signal *ws, ws->mode = WSO_MODE_SERVICE; } } + gc_free(&gc); } /* set the ctrl handler in both console and service modes */ if (!SetConsoleCtrlHandler((PHANDLER_ROUTINE) win_ctrl_handler, true))