From patchwork Fri May 21 17:32:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Selva Nair X-Patchwork-Id: 1834 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director11.mail.ord1d.rsapps.net ([172.31.255.6]) by backend30.mail.ord1d.rsapps.net with LMTP id 4K0dCaR7qGBOagAAIUCqbw (envelope-from ) for ; Fri, 21 May 2021 23:33:56 -0400 Received: from proxy9.mail.iad3b.rsapps.net ([172.31.255.6]) by director11.mail.ord1d.rsapps.net with LMTP id KK8GCaR7qGD6QwAAvGGmqA (envelope-from ) for ; Fri, 21 May 2021 23:33:56 -0400 Received: from smtp32.gate.iad3b ([172.31.255.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy9.mail.iad3b.rsapps.net with LMTPS id UHDtAaR7qGA9GQAAC4PSzw (envelope-from ) for ; Fri, 21 May 2021 23:33:56 -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: smtp32.gate.iad3b.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; dkim=fail (signature verification failed) header.d=gmail.com; dmarc=fail (p=none; dis=none) header.from=gmail.com X-Suspicious-Flag: YES X-Classification-ID: 88e77c3a-baae-11eb-8f3e-5254006a2e70-1-1 Received: from [216.105.38.7] ([216.105.38.7:54762] helo=lists.sourceforge.net) by smtp32.gate.iad3b.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 9B/43-14195-3AB78A06; Fri, 21 May 2021 23:33:55 -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 1lkINy-0008PG-IT; Sat, 22 May 2021 03:33:10 +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 1lkINx-0008P7-3q for openvpn-devel@lists.sourceforge.net; Sat, 22 May 2021 03:33:09 +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: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:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=QoU4m0/p5LOgzflkioE+lShYVcNxdNr9VF/IQE7mc8g=; b=Xn6BVtPpYeUxHjq5dWJAy8oQBa 6kWu4xO+p0Y8rIna+pVhg0YZLLdrE0Qt9pKVmg5YwpaD0cFbHpnKSSQTFsTeE0JOHqm6xjZNN1KeV tqUcQWKKuvsjue10rxZnhoPIcFVpOo1CoyLQYj7/Q1G7dGEOppPQCuBdc3Y8sKfsvN8U=; 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: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:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=QoU4m0/p5LOgzflkioE+lShYVcNxdNr9VF/IQE7mc8g=; b=OWIK5BQFewsIEaejYVeHjB/k1t jXApAH9O/EpWkI0Kjhr2mnunSPcDdBPu9UCWy9S1uWnxgK61lTfTVF2U4FQzLet3p/oQQr7DmVOtL NTNuAVGv8eETAkB335i0I4qjKQQIWP0GChtznmiRkTt5QOTxBmmI42HV8Ivi8JraBFaU=; Received: from mail-qt1-f177.google.com ([209.85.160.177]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.92.2) id 1lkINl-001Pky-BB for openvpn-devel@lists.sourceforge.net; Sat, 22 May 2021 03:33:09 +0000 Received: by mail-qt1-f177.google.com with SMTP id 1so16846833qtb.0 for ; Fri, 21 May 2021 20:32:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QoU4m0/p5LOgzflkioE+lShYVcNxdNr9VF/IQE7mc8g=; b=FFiuWMly56+muhiC6MGzktS6NKi99D5OapMInsKOLYQKFX4BeISLdiFEk8aE/EzKUO l25FYhpug8KCEHexpsMad7Sw28bLSEBhrT6MmAaOHMtlKTOLF9pGctsLb4U0iF/OWd7u 976puR2X+zf3L8UHfhwzuSVAZqbSo6M7raj/Z7ZdBAEx6yUT0g/ewfUoRe9jqacapVyj y9hOo8eduiyV+CdhbfNsEQndcgwhON2t8ngFQY+VvedJLS21mvI6wZmjLAOpNaY8N+/h 0hPe2gIDXxRwF31EJKSglOvUsGxNvBqgy3uYW69ali1ItR/wBUtIsHTNYKrPw4LnZBtZ XN0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QoU4m0/p5LOgzflkioE+lShYVcNxdNr9VF/IQE7mc8g=; b=aSd7AS9pac8JK9LtFW1XuyK8Vi+CmrcSjTfg8Vcb71s1lWvQ+LqYok3BfT4j7Q1cT2 iyZOVfZtt3iXJ/XuAGJtpyVRc8yChAHtvZ1nsmJ+AeHsKGtLgYr2bPNpUNDwRAkU35+O bnO0d6URmKR3Je6Tk6g0mHB9CtxSLAG7xFhSQMY1KbBc6NlF8HFqPCJE/zz6gRm53Z8d 7vH+tkmj46/K9dndCwdzyLW9WQF+itw/efY8htaMMMOabYpJ8fv0Gq47dm7ozRVaD3oy QUJkfitTYlBFWE4v0SqLykcm0ZvEukiLZ2ebI3t5DFDMFyTK55zvdAaikEL/tQzexTvy KiXA== X-Gm-Message-State: AOAM5311ZPYUKmyKcy5LTLFHeel7Oe4kZKIGhoQIaW6wQm3pPLvAWxee /ECNRrsZ/zS0cRcuzlhgGlKITinq5Mh5iA== X-Google-Smtp-Source: ABdhPJzPjMUoGsRCVrZMNMLpbj1KYF7CPl5M7xWkOwkDLol8jLEhpJqmY/Pvq6duxXXmMQDdnRtg5g== X-Received: by 2002:ac8:5318:: with SMTP id t24mr14895355qtn.114.1621654370479; Fri, 21 May 2021 20:32:50 -0700 (PDT) Received: from uranus.home.sansel.ca (bras-vprn-tnhlon4053w-lp130-01-70-51-222-236.dsl.bell.ca. [70.51.222.236]) by smtp.gmail.com with ESMTPSA id q12sm5907187qtl.13.2021.05.21.20.32.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 May 2021 20:32:50 -0700 (PDT) From: selva.nair@gmail.com To: openvpn-devel@lists.sourceforge.net Date: Fri, 21 May 2021 23:32:31 -0400 Message-Id: <20210522033232.20548-2-selva.nair@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210522033232.20548-1-selva.nair@gmail.com> References: <20210522033232.20548-1-selva.nair@gmail.com> MIME-Version: 1.0 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 (selva.nair[at]gmail.com) -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.160.177 listed in list.dnswl.org] 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.160.177 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -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_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-Headers-End: 1lkINl-001Pky-BB Subject: [Openvpn-devel] [PATCH 2/3] Use C standard compliant format specs in wprintf functions 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 From: Selva Nair - Use %ls for wchar_t * and %hs for char * variables This makes it possible to build correctly with or without __USE_MINGW_ANIS_STDIO defined. When this define is not used all printf/scanf family functions are resolved from the windows runtime MSVCRT. Newer (since version 8) mingw-w64 versions have started automatically enabling this macro under some feature sets such as _GNU_SOURCE and C99. The changes should not affect MSVC builds as Windows support these format specifications. Signed-off-by: Selva Nair Acked-by: Lev Stipakov --- src/openvpn/tun.c | 2 +- src/openvpn/win32.c | 4 ++-- src/openvpnserv/common.c | 20 ++++++++-------- src/openvpnserv/interactive.c | 43 +++++++++++++++++------------------ src/openvpnserv/service.c | 34 +++++++++++++-------------- src/openvpnserv/validate.c | 6 ++--- 6 files changed, 54 insertions(+), 55 deletions(-) diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index 4ef34e4e..f9cf725e 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -4833,7 +4833,7 @@ get_adapter_index_method_1(const char *guid) DWORD index; ULONG aindex; wchar_t wbuf[256]; - openvpn_swprintf(wbuf, SIZE(wbuf), L"\\DEVICE\\TCPIP_%S", guid); + openvpn_swprintf(wbuf, SIZE(wbuf), L"\\DEVICE\\TCPIP_%hs", guid); if (GetAdapterIndex(wbuf, &aindex) != NO_ERROR) { index = TUN_ADAPTER_INDEX_INVALID; diff --git a/src/openvpn/win32.c b/src/openvpn/win32.c index 629ebbd9..d0e81d3a 100644 --- a/src/openvpn/win32.c +++ b/src/openvpn/win32.c @@ -1040,13 +1040,13 @@ openvpn_execve(const struct argv *a, const struct env_set *es, const unsigned in } else { - msg(M_WARN|M_ERRNO, "openvpn_execve: GetExitCodeProcess %S failed", cmd); + msg(M_WARN|M_ERRNO, "openvpn_execve: GetExitCodeProcess %ls failed", cmd); } CloseHandle(proc_info.hProcess); } else { - msg(M_WARN|M_ERRNO, "openvpn_execve: CreateProcess %S failed", cmd); + msg(M_WARN|M_ERRNO, "openvpn_execve: CreateProcess %ls failed", cmd); } free(env); gc_free(&gc); diff --git a/src/openvpnserv/common.c b/src/openvpnserv/common.c index 2f711ebc..35532f2b 100644 --- a/src/openvpnserv/common.c +++ b/src/openvpnserv/common.c @@ -75,7 +75,7 @@ GetRegString(HKEY key, LPCTSTR value, LPTSTR data, DWORD size, LPCTSTR default_v if (status != ERROR_SUCCESS) { SetLastError(status); - return MsgToEventLog(M_SYSERR, TEXT("Error querying registry value: HKLM\\SOFTWARE\\" PACKAGE_NAME "%s\\%s"), service_instance, value); + return MsgToEventLog(M_SYSERR, TEXT("Error querying registry value: HKLM\\SOFTWARE\\" PACKAGE_NAME "%ls\\%ls"), service_instance, value); } return ERROR_SUCCESS; @@ -93,13 +93,13 @@ GetOpenvpnSettings(settings_t *s) TCHAR install_path[MAX_PATH]; TCHAR default_value[MAX_PATH]; - openvpn_swprintf(reg_path, _countof(reg_path), TEXT("SOFTWARE\\" PACKAGE_NAME "%s"), service_instance); + openvpn_swprintf(reg_path, _countof(reg_path), TEXT("SOFTWARE\\" PACKAGE_NAME "%ls"), service_instance); LONG status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, reg_path, 0, KEY_READ, &key); if (status != ERROR_SUCCESS) { SetLastError(status); - return MsgToEventLog(M_SYSERR, TEXT("Could not open Registry key HKLM\\%s not found"), reg_path); + return MsgToEventLog(M_SYSERR, TEXT("Could not open Registry key HKLM\\%ls not found"), reg_path); } /* The default value of REG_KEY is the install path */ @@ -110,7 +110,7 @@ GetOpenvpnSettings(settings_t *s) goto out; } - openvpn_swprintf(default_value, _countof(default_value), TEXT("%s\\bin\\openvpn.exe"), + openvpn_swprintf(default_value, _countof(default_value), TEXT("%ls\\bin\\openvpn.exe"), install_path); error = GetRegString(key, TEXT("exe_path"), s->exe_path, sizeof(s->exe_path), default_value); if (error != ERROR_SUCCESS) @@ -118,7 +118,7 @@ GetOpenvpnSettings(settings_t *s) goto out; } - openvpn_swprintf(default_value, _countof(default_value), TEXT("%s\\config"), install_path); + openvpn_swprintf(default_value, _countof(default_value), TEXT("%ls\\config"), install_path); error = GetRegString(key, TEXT("config_dir"), s->config_dir, sizeof(s->config_dir), default_value); if (error != ERROR_SUCCESS) @@ -133,7 +133,7 @@ GetOpenvpnSettings(settings_t *s) goto out; } - openvpn_swprintf(default_value, _countof(default_value), TEXT("%s\\log"), install_path); + openvpn_swprintf(default_value, _countof(default_value), TEXT("%ls\\log"), install_path); error = GetRegString(key, TEXT("log_dir"), s->log_dir, sizeof(s->log_dir), default_value); if (error != ERROR_SUCCESS) { @@ -184,7 +184,7 @@ GetOpenvpnSettings(settings_t *s) else { SetLastError(ERROR_INVALID_DATA); - error = MsgToEventLog(M_SYSERR, TEXT("Unknown priority name: %s"), priority); + error = MsgToEventLog(M_SYSERR, TEXT("Unknown priority name: %ls"), priority); goto out; } @@ -200,7 +200,7 @@ GetOpenvpnSettings(settings_t *s) else { SetLastError(ERROR_INVALID_DATA); - error = MsgToEventLog(M_ERR, TEXT("Log file append flag (given as '%s') must be '0' or '1'"), append); + error = MsgToEventLog(M_ERR, TEXT("Log file append flag (given as '%ls') must be '0' or '1'"), append); goto out; } @@ -229,7 +229,7 @@ GetLastErrorText() else { tmp[wcslen(tmp) - 2] = TEXT('\0'); /* remove CR/LF characters */ - openvpn_swprintf(buf, _countof(buf), TEXT("%s (0x%x)"), tmp, error); + openvpn_swprintf(buf, _countof(buf), TEXT("%ls (0x%x)"), tmp, error); } if (tmp) @@ -260,7 +260,7 @@ MsgToEventLog(DWORD flags, LPCTSTR format, ...) if (hEventSource != NULL) { openvpn_swprintf(msg[0], _countof(msg[0]), - TEXT("%s%s%s: %s"), APPNAME, service_instance, + TEXT("%ls%ls%ls: %ls"), APPNAME, service_instance, (flags & MSG_FLAGS_ERROR) ? TEXT(" error") : TEXT(""), err_msg); va_start(arglist, format); diff --git a/src/openvpnserv/interactive.c b/src/openvpnserv/interactive.c index 57e9697d..03237c95 100644 --- a/src/openvpnserv/interactive.c +++ b/src/openvpnserv/interactive.c @@ -307,7 +307,7 @@ ReturnProcessId(HANDLE pipe, DWORD pid, DWORD count, LPHANDLE events) * Same format as error messages (3 line string) with error = 0 in * 0x%08x format, PID on line 2 and a description "Process ID" on line 3 */ - openvpn_swprintf(buf, _countof(buf), L"0x%08x\n0x%08x\n%s", 0, pid, msg); + openvpn_swprintf(buf, _countof(buf), L"0x%08x\n0x%08x\n%ls", 0, pid, msg); WritePipeAsync(pipe, buf, (DWORD)(wcslen(buf) * 2), count, events); } @@ -369,13 +369,13 @@ ValidateOptions(HANDLE pipe, const WCHAR *workdir, const WCHAR *options, WCHAR * int argc; BOOL ret = FALSE; int i; - const WCHAR *msg1 = L"You have specified a config file location (%s relative to %s)" + const WCHAR *msg1 = L"You have specified a config file location (%ls relative to %ls)" L" that requires admin approval. This error may be avoided" - L" by adding your account to the \"%s\" group"; + L" by adding your account to the \"%ls\" group"; - const WCHAR *msg2 = L"You have specified an option (%s) that may be used" + const WCHAR *msg2 = L"You have specified an option (%ls) that may be used" L" only with admin approval. This error may be avoided" - L" by adding your account to the \"%s\" group"; + L" by adding your account to the \"%ls\" group"; argv = CommandLineToArgvW(options, &argc); @@ -574,7 +574,7 @@ ConvertInterfaceNameToIndex(const wchar_t *ifname, NET_IFINDEX *index) } if (err != ERROR_SUCCESS) { - MsgToEventLog(M_ERR, L"Failed to find interface index for <%s>", ifname); + MsgToEventLog(M_ERR, L"Failed to find interface index for <%ls>", ifname); } return err; } @@ -772,8 +772,7 @@ BlockDNSErrHandler(DWORD err, const char *msg) err_str = buf; } - MsgToEventLog(M_ERR, L"%S (status = %lu): %s", msg, err, err_str); - + MsgToEventLog(M_ERR, L"%hs (status = %lu): %ls", msg, err, err_str); } /* Use an always-true match_fn to get the head of the list */ @@ -901,17 +900,17 @@ ExecCommand(const WCHAR *argv0, const WCHAR *cmdline, DWORD timeout) /* kill without impunity */ TerminateProcess(pi.hProcess, exit_code); - MsgToEventLog(M_ERR, TEXT("ExecCommand: \"%s %s\" killed after timeout"), + MsgToEventLog(M_ERR, TEXT("ExecCommand: \"%ls %ls\" killed after timeout"), argv0, cmdline); } else if (exit_code) { - MsgToEventLog(M_ERR, TEXT("ExecCommand: \"%s %s\" exited with status = %lu"), + MsgToEventLog(M_ERR, TEXT("ExecCommand: \"%ls %ls\" exited with status = %lu"), argv0, cmdline, exit_code); } else { - MsgToEventLog(M_INFO, TEXT("ExecCommand: \"%s %s\" completed"), argv0, cmdline); + MsgToEventLog(M_INFO, TEXT("ExecCommand: \"%ls %ls\" completed"), argv0, cmdline); } CloseHandle(pi.hProcess); @@ -920,7 +919,7 @@ ExecCommand(const WCHAR *argv0, const WCHAR *cmdline, DWORD timeout) else { exit_code = GetLastError(); - MsgToEventLog(M_SYSERR, TEXT("ExecCommand: could not run \"%s %s\" :"), + MsgToEventLog(M_SYSERR, TEXT("ExecCommand: could not run \"%ls %ls\" :"), argv0, cmdline); } @@ -953,7 +952,7 @@ RegisterDNS(LPVOID unused) HANDLE wait_handles[2] = {rdns_semaphore, exit_event}; - openvpn_swprintf(ipcfg, MAX_PATH, L"%s\\%s", get_win_sys_path(), L"ipconfig.exe"); + openvpn_swprintf(ipcfg, MAX_PATH, L"%ls\\%ls", get_win_sys_path(), L"ipconfig.exe"); if (WaitForMultipleObjects(2, wait_handles, FALSE, timeout) == WAIT_OBJECT_0) { @@ -1032,12 +1031,12 @@ netsh_dns_cmd(const wchar_t *action, const wchar_t *proto, const wchar_t *if_nam } /* Path of netsh */ - openvpn_swprintf(argv0, _countof(argv0), L"%s\\%s", get_win_sys_path(), L"netsh.exe"); + openvpn_swprintf(argv0, _countof(argv0), L"%ls\\%ls", get_win_sys_path(), L"netsh.exe"); /* cmd template: * netsh interface $proto $action dns $if_name $addr [validate=no] */ - const wchar_t *fmt = L"netsh interface %s %s dns \"%s\" %s"; + const wchar_t *fmt = L"netsh interface %ls %ls dns \"%ls\" %ls"; /* max cmdline length in wchars -- include room for worst case and some */ size_t ncmdline = wcslen(fmt) + wcslen(if_name) + wcslen(addr) + 32 + 1; @@ -1078,17 +1077,17 @@ wmic_nicconfig_cmd(const wchar_t *action, const NET_IFINDEX if_index, wchar_t *cmdline = NULL; int timeout = 10000; /* in msec */ - openvpn_swprintf(argv0, _countof(argv0), L"%s\\%s", get_win_sys_path(), L"wbem\\wmic.exe"); + openvpn_swprintf(argv0, _countof(argv0), L"%ls\\%ls", get_win_sys_path(), L"wbem\\wmic.exe"); const wchar_t *fmt; /* comma separated list must be enclosed in parenthesis */ if (data && wcschr(data, L',')) { - fmt = L"wmic nicconfig where (InterfaceIndex=%ld) call %s (%s)"; + fmt = L"wmic nicconfig where (InterfaceIndex=%ld) call %ls (%ls)"; } else { - fmt = L"wmic nicconfig where (InterfaceIndex=%ld) call %s \"%s\""; + fmt = L"wmic nicconfig where (InterfaceIndex=%ld) call %ls \"%ls\""; } size_t ncmdline = wcslen(fmt) + 20 + wcslen(action) /* max 20 for ifindex */ @@ -1284,7 +1283,7 @@ HandleEnableDHCPMessage(const enable_dhcp_message_t *dhcp) wchar_t argv0[MAX_PATH]; /* Path of netsh */ - openvpn_swprintf(argv0, _countof(argv0), L"%s\\%s", get_win_sys_path(), L"netsh.exe"); + openvpn_swprintf(argv0, _countof(argv0), L"%ls\\%ls", get_win_sys_path(), L"netsh.exe"); /* cmd template: * netsh interface ipv4 set address name=$if_index source=dhcp @@ -1774,7 +1773,7 @@ RunOpenvpn(LPVOID p) } openvpn_swprintf(ovpn_pipe_name, _countof(ovpn_pipe_name), - TEXT("\\\\.\\pipe\\" PACKAGE "%s\\service_%lu"), service_instance, GetCurrentThreadId()); + TEXT("\\\\.\\pipe\\" PACKAGE "%ls\\service_%lu"), service_instance, GetCurrentThreadId()); ovpn_pipe = CreateNamedPipe(ovpn_pipe_name, PIPE_ACCESS_DUPLEX | FILE_FLAG_FIRST_PIPE_INSTANCE | FILE_FLAG_OVERLAPPED, PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, 1, 128, 128, 0, NULL); @@ -1806,7 +1805,7 @@ RunOpenvpn(LPVOID p) ReturnLastError(pipe, L"malloc"); goto out; } - openvpn_swprintf(cmdline, cmdline_size, L"openvpn %s --msg-channel %lu", + openvpn_swprintf(cmdline, cmdline_size, L"openvpn %ls --msg-channel %lu", sud.options, svc_pipe); if (!CreateEnvironmentBlock(&user_env, imp_token, FALSE)) @@ -1972,7 +1971,7 @@ CreateClientPipeInstance(VOID) initialized = TRUE; } - openvpn_swprintf(pipe_name, _countof(pipe_name), TEXT("\\\\.\\pipe\\" PACKAGE "%s\\service"), service_instance); + openvpn_swprintf(pipe_name, _countof(pipe_name), TEXT("\\\\.\\pipe\\" PACKAGE "%ls\\service"), service_instance); pipe = CreateNamedPipe(pipe_name, flags, PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE, PIPE_UNLIMITED_INSTANCES, 1024, 1024, 0, NULL); diff --git a/src/openvpnserv/service.c b/src/openvpnserv/service.c index 65b88faa..c27878dc 100644 --- a/src/openvpnserv/service.c +++ b/src/openvpnserv/service.c @@ -63,7 +63,7 @@ CmdInstallServices() if (GetModuleFileName(NULL, path + 1, _countof(path) - 2) == 0) { - wprintf(TEXT("Unable to install service - %s\n"), GetLastErrorText()); + wprintf(TEXT("Unable to install service - %ls\n"), GetLastErrorText()); return 1; } @@ -73,7 +73,7 @@ CmdInstallServices() svc_ctl_mgr = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT | SC_MANAGER_CREATE_SERVICE); if (svc_ctl_mgr == NULL) { - wprintf(TEXT("OpenSCManager failed - %s\n"), GetLastErrorText()); + wprintf(TEXT("OpenSCManager failed - %ls\n"), GetLastErrorText()); return 1; } @@ -91,13 +91,13 @@ CmdInstallServices() NULL, NULL); if (service) { - wprintf(TEXT("%s installed.\n"), openvpn_service[i].display_name); + wprintf(TEXT("%ls installed.\n"), openvpn_service[i].display_name); CloseServiceHandle(service); --ret; } else { - wprintf(TEXT("CreateService failed - %s\n"), GetLastErrorText()); + wprintf(TEXT("CreateService failed - %ls\n"), GetLastErrorText()); } } @@ -116,7 +116,7 @@ CmdStartService(openvpn_service_type type) svc_ctl_mgr = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); if (svc_ctl_mgr == NULL) { - wprintf(TEXT("OpenSCManager failed - %s\n"), GetLastErrorText()); + wprintf(TEXT("OpenSCManager failed - %ls\n"), GetLastErrorText()); return 1; } @@ -130,14 +130,14 @@ CmdStartService(openvpn_service_type type) } else { - wprintf(TEXT("StartService failed - %s\n"), GetLastErrorText()); + wprintf(TEXT("StartService failed - %ls\n"), GetLastErrorText()); } CloseServiceHandle(service); } else { - wprintf(TEXT("OpenService failed - %s\n"), GetLastErrorText()); + wprintf(TEXT("OpenService failed - %ls\n"), GetLastErrorText()); } CloseServiceHandle(svc_ctl_mgr); @@ -156,7 +156,7 @@ CmdRemoveServices() svc_ctl_mgr = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT); if (svc_ctl_mgr == NULL) { - wprintf(TEXT("OpenSCManager failed - %s\n"), GetLastErrorText()); + wprintf(TEXT("OpenSCManager failed - %ls\n"), GetLastErrorText()); return 1; } @@ -167,14 +167,14 @@ CmdRemoveServices() DELETE | SERVICE_STOP | SERVICE_QUERY_STATUS); if (service == NULL) { - wprintf(TEXT("OpenService failed - %s\n"), GetLastErrorText()); + wprintf(TEXT("OpenService failed - %ls\n"), GetLastErrorText()); goto out; } /* try to stop the service */ if (ControlService(service, SERVICE_CONTROL_STOP, &status)) { - wprintf(TEXT("Stopping %s."), ovpn_svc->display_name); + wprintf(TEXT("Stopping %ls."), ovpn_svc->display_name); Sleep(1000); while (QueryServiceStatus(service, &status)) @@ -192,23 +192,23 @@ CmdRemoveServices() if (status.dwCurrentState == SERVICE_STOPPED) { - wprintf(TEXT("\n%s stopped.\n"), ovpn_svc->display_name); + wprintf(TEXT("\n%ls stopped.\n"), ovpn_svc->display_name); } else { - wprintf(TEXT("\n%s failed to stop.\n"), ovpn_svc->display_name); + wprintf(TEXT("\n%ls failed to stop.\n"), ovpn_svc->display_name); } } /* now remove the service */ if (DeleteService(service)) { - wprintf(TEXT("%s removed.\n"), ovpn_svc->display_name); + wprintf(TEXT("%ls removed.\n"), ovpn_svc->display_name); --ret; } else { - wprintf(TEXT("DeleteService failed - %s\n"), GetLastErrorText()); + wprintf(TEXT("DeleteService failed - %ls\n"), GetLastErrorText()); } CloseServiceHandle(service); @@ -274,9 +274,9 @@ _tmain(int argc, TCHAR *argv[]) } else { - wprintf(TEXT("%s -install to install the interactive service\n"), APPNAME); - wprintf(TEXT("%s -start [name] to start the service (name = \"interactive\" is optional)\n"), APPNAME); - wprintf(TEXT("%s -remove to remove the service\n"), APPNAME); + wprintf(TEXT("%ls -install to install the interactive service\n"), APPNAME); + wprintf(TEXT("%ls -start [name] to start the service (name = \"interactive\" is optional)\n"), APPNAME); + wprintf(TEXT("%ls -remove to remove the service\n"), APPNAME); wprintf(TEXT("\nService run-time parameters:\n")); wprintf(TEXT("-instance interactive \n") diff --git a/src/openvpnserv/validate.c b/src/openvpnserv/validate.c index b3eac963..0b1bc807 100644 --- a/src/openvpnserv/validate.c +++ b/src/openvpnserv/validate.c @@ -68,7 +68,7 @@ CheckConfigPath(const WCHAR *workdir, const WCHAR *fname, const settings_t *s) /* convert fname to full path */ if (PathIsRelativeW(fname) ) { - openvpn_swprintf(tmp, _countof(tmp), L"%s\\%s", workdir, fname); + openvpn_swprintf(tmp, _countof(tmp), L"%ls\\%ls", workdir, fname); config_file = tmp; } else @@ -182,7 +182,7 @@ IsAuthorizedUser(PSID sid, const HANDLE token, const WCHAR *ovpn_admin_group) ret = IsUserInGroup(sid, token_groups, admin_group[i]); if (ret) { - MsgToEventLog(M_INFO, TEXT("Authorizing user '%s@%s' by virtue of membership in group '%s'"), + MsgToEventLog(M_INFO, TEXT("Authorizing user '%ls@%ls' by virtue of membership in group '%ls'"), username, domain, admin_group[i]); goto out; } @@ -302,7 +302,7 @@ IsUserInGroup(PSID sid, const PTOKEN_GROUPS token_groups, const WCHAR *group_nam if (err != NERR_Success && err != NERR_GroupNotFound) { SetLastError(err); - MsgToEventLog(M_SYSERR, TEXT("In NetLocalGroupGetMembers for group '%s'"), group_name); + MsgToEventLog(M_SYSERR, TEXT("In NetLocalGroupGetMembers for group '%ls'"), group_name); } return ret;