From patchwork Fri May 21 17:32:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Selva Nair X-Patchwork-Id: 1835 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director12.mail.ord1d.rsapps.net ([172.31.255.6]) by backend30.mail.ord1d.rsapps.net with LMTP id QDQbL6R7qGBOagAAIUCqbw (envelope-from ) for ; Fri, 21 May 2021 23:33:56 -0400 Received: from proxy3.mail.iad3b.rsapps.net ([172.31.255.6]) by director12.mail.ord1d.rsapps.net with LMTP id eNchL6R7qGBXIgAAIasKDg (envelope-from ) for ; Fri, 21 May 2021 23:33:56 -0400 Received: from smtp38.gate.iad3b ([172.31.255.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy3.mail.iad3b.rsapps.net with LMTPS id oBLRJqR7qGCLGgAAM8Wetg (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: smtp38.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: 894b6ba0-baae-11eb-81a8-5254006f0979-1-1 Received: from [216.105.38.7] ([216.105.38.7:41526] helo=lists.sourceforge.net) by smtp38.gate.iad3b.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 6D/04-24528-4AB78A06; Fri, 21 May 2021 23:33:56 -0400 Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1lkINx-0003Jk-6M; Sat, 22 May 2021 03:33:09 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lkINv-0003Jd-N2 for openvpn-devel@lists.sourceforge.net; Sat, 22 May 2021 03:33:07 +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=Oc5f2G9v2hWEl1cmqvltlMZ/FUKMNve7PVaaSghmauM=; b=Xu33ArZh+hbhtjVIQJ/yaoSmCD 0bhq4HMMthXUIQbSPufJP/NRaFa2jet7PzMyvjj1q6/b8brVN3n8qxWvOTbmFaMLWkny11UTCUQSI 992LfcagUhUiyNvz5hmlYu8GvHz/hbboJtjuswnvEAFq8cH4gWy/Wbu/2lUO4mtaWblY=; 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=Oc5f2G9v2hWEl1cmqvltlMZ/FUKMNve7PVaaSghmauM=; b=D6kk2f27rVnNa2j/ZqpCCD50lb 2Xbee/X83y15UFz1f2QWYSwE1E1LMlynVisS09C7UZrnMzSWVEYTla7QGOr6qv2q6DYTaer7j4fVU ospoSUIn2x21M5ARMl5ZJtA9NGFo/oZxm/2hjGkgg52bCGP5SG2aXDJKYwqjkr4Ilwp8=; Received: from mail-qk1-f175.google.com ([209.85.222.175]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.92.3) id 1lkINo-0000W2-7a for openvpn-devel@lists.sourceforge.net; Sat, 22 May 2021 03:33:08 +0000 Received: by mail-qk1-f175.google.com with SMTP id j189so1048340qkf.2 for ; Fri, 21 May 2021 20:33:01 -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=Oc5f2G9v2hWEl1cmqvltlMZ/FUKMNve7PVaaSghmauM=; b=DqY6/09lvVHnd2Y8ZG46L5HIvJQDaHwhwzFZLpfGix0AnThcjAEFYfa/O3jPBVdhT8 1Z2U0wLiBIov/U825hKka7f0EvMrRM0/uxu+gr5Q9Xd6l3ynvel+u1rewWW/IzdXi7Au yC1lyfzsjqJBadYt7ky2+9zC1FBl/9evq16WOoRPw0nE28ynVa822qx318imBUFqwRPd vJ+0ZFMlkZPPaOxAnnbv8IxikkPIDiB5JcKFiZuYq4OkRcauSJOpcYKAPsrfDZXXuU/u a5yn2WBs7Zrzq+tQqjpoYNG4XkrvSKC/xxo9pmS9iWsp9xYM73fnWD4+Eccz+rFHdu7J aPgw== 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=Oc5f2G9v2hWEl1cmqvltlMZ/FUKMNve7PVaaSghmauM=; b=H8+mJkdntJwJusvNxVefRtD1OMsGL/WRJYWcTkrsW4m16pZ688zXnO3j8wtSKto7ni cGMD/0dKBqmibx0GZTUoiJMDhXmNnrlFhT8fivob/B+9W1hfoE2puqXLmiCOaiZ23yUF 05ANaOXRuJUwXV3NE04PM6bPMJmWMrAGVclf+nB9HW5ifpDzdS7NzlGZRK6CBKkSsuGR f2OOaRBE1kgxsq0jFNnYfXHyFG78rQaqf+qYbaDtKmxsQiM1cs6axpcuRsrpJy0geQqs nrtpNqVjCu+80+iQxy3rHPnda+iQR7JeXeQRzkybBr6mxWPlM8TAWyaRuqM85HivDIKw 9kmw== X-Gm-Message-State: AOAM530Yf+icjf3aX2P2yifQp7HhUIYouc62TYQQ+NjCf8YLwsRHhvJu M9k4fQJ9HTQbkdETD2ZLa6xWYZ6/wAhuEA== X-Google-Smtp-Source: ABdhPJz/aXsGqJO9bm8fQDcpWnm0oeMEIEMONWyE36YExION8gF05mh8ovBXe3b/KwKoedZR5oVNNw== X-Received: by 2002:a05:620a:22b9:: with SMTP id p25mr16021162qkh.319.1621654375245; Fri, 21 May 2021 20:32:55 -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.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 May 2021 20:32:54 -0700 (PDT) From: selva.nair@gmail.com To: openvpn-devel@lists.sourceforge.net Date: Fri, 21 May 2021 23:32:32 -0400 Message-Id: <20210522033232.20548-3-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 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.222.175 listed in list.dnswl.org] 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.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.222.175 listed in wl.mailspike.net] -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 X-Headers-End: 1lkINo-0000W2-7a Subject: [Openvpn-devel] [PATCH 3/3] Print format spec changes for tapctl and openvpnmscia 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 The tapctl and openvpnmscia codebase is written with an intent of supporting both unicode and ansi builds. This patch does not attempt to change that although non-unicode support looks untested and buggy. The main change is to replace %s by PRIsLPTSR that is defined as %ls or %s depending on _UNICODE is defined ot not. Signed-off-by: Selva Nair --- src/openvpnmsica/openvpnmsica.c | 6 +++-- src/tapctl/main.c | 39 +++++++++++++++++++++------------ src/tapctl/tap.c | 3 ++- 3 files changed, 31 insertions(+), 17 deletions(-) diff --git a/src/openvpnmsica/openvpnmsica.c b/src/openvpnmsica/openvpnmsica.c index 96652117..1a6f7e86 100644 --- a/src/openvpnmsica/openvpnmsica.c +++ b/src/openvpnmsica/openvpnmsica.c @@ -108,7 +108,8 @@ _debug_popup(_In_z_ LPCTSTR szFunctionName) /* Compose pop-up title. The dialog title will contain function name to ease the process * locating. Mind that Visual Studio displays window titles on the process list. */ - _stprintf_s(szTitle, _countof(szTitle), TEXT("%s v%s"), szFunctionName, TEXT(PACKAGE_VERSION)); + _stprintf_s(szTitle, _countof(szTitle), TEXT("%") TEXT(PRIsLPTSTR) TEXT("v%") TEXT(PRIsLPTSTR), + szFunctionName, TEXT(PACKAGE_VERSION)); /* Get process name. */ GetModuleFileName(NULL, szProcessPath, _countof(szProcessPath)); @@ -118,7 +119,8 @@ _debug_popup(_In_z_ LPCTSTR szFunctionName) /* Compose the pop-up message. */ _stprintf_s( szMessage, _countof(szMessage), - TEXT("The %s process (PID: %u) has started to execute the %s custom action.\r\n") + TEXT("The %") TEXT(PRIsLPTSTR) TEXT(" process (PID: %u) has started to execute the %" + TEXT(PRIsLPTSTR) TEXT(" custom action.\r\n") TEXT("\r\n") TEXT("If you would like to debug the custom action, attach a debugger to this process and set breakpoints before dismissing this dialog.\r\n") TEXT("\r\n") diff --git a/src/tapctl/main.c b/src/tapctl/main.c index 3350bf1f..81addaef 100644 --- a/src/tapctl/main.c +++ b/src/tapctl/main.c @@ -49,7 +49,7 @@ const TCHAR title_string[] = ; static const TCHAR usage_message[] = - TEXT("%s\n") + TEXT("%") TEXT(PRIsLPTSTR) TEXT("\n") TEXT("\n") TEXT("Usage:\n") TEXT("\n") @@ -66,7 +66,7 @@ static const TCHAR usage_message[] = ; static const TCHAR usage_message_create[] = - TEXT("%s\n") + TEXT("%") TEXT(PRIsLPTSTR) TEXT("\n") TEXT("\n") TEXT("Creates a new TUN/TAP adapter\n") TEXT("\n") @@ -91,7 +91,7 @@ static const TCHAR usage_message_create[] = ; static const TCHAR usage_message_list[] = - TEXT("%s\n") + TEXT("%") TEXT(PRIsLPTSTR) TEXT("\n") TEXT("\n") TEXT("Lists TUN/TAP adapters\n") TEXT("\n") @@ -110,7 +110,7 @@ static const TCHAR usage_message_list[] = ; static const TCHAR usage_message_delete[] = - TEXT("%s\n") + TEXT("%") TEXT(PRIsLPTSTR) TEXT("\n") TEXT("\n") TEXT("Deletes the specified network adapter\n") TEXT("\n") @@ -170,7 +170,8 @@ _tmain(int argc, LPCTSTR argv[]) } else { - _ftprintf(stderr, TEXT("Unknown command \"%s\". Please, use \"tapctl help\" to list supported commands.\n"), argv[2]); + _ftprintf(stderr, TEXT("Unknown command \"%") TEXT(PRIsLPTSTR) + TEXT("\". Please, use \"tapctl help\" to list supported commands.\n"), argv[2]); } return 1; @@ -194,7 +195,9 @@ _tmain(int argc, LPCTSTR argv[]) } else { - _ftprintf(stderr, TEXT("Unknown option \"%s\". Please, use \"tapctl help create\" to list supported options. Ignored.\n"), argv[i]); + _ftprintf(stderr, TEXT("Unknown option \"%") TEXT(PRIsLPTSTR) + TEXT("\". Please, use \"tapctl help create\" to list supported options. Ignored.\n"), + argv[i]); } } @@ -230,7 +233,8 @@ _tmain(int argc, LPCTSTR argv[]) if (_tcsicmp(szName, pAdapter->szName) == 0) { StringFromIID((REFIID)&pAdapter->guid, &szAdapterId); - _ftprintf(stderr, TEXT("Adapter \"%s\" already exists (GUID %") TEXT(PRIsLPOLESTR) TEXT(").\n"), pAdapter->szName, szAdapterId); + _ftprintf(stderr, TEXT("Adapter \"%") TEXT(PRIsLPTSTR) TEXT("\" already exists (GUID %") + TEXT(PRIsLPOLESTR) TEXT(").\n"), pAdapter->szName, szAdapterId); CoTaskMemFree(szAdapterId); iResult = 1; goto create_cleanup_pAdapterList; } @@ -241,7 +245,9 @@ _tmain(int argc, LPCTSTR argv[]) if (dwResult != ERROR_SUCCESS) { StringFromIID((REFIID)&guidAdapter, &szAdapterId); - _ftprintf(stderr, TEXT("Renaming TUN/TAP adapter %") TEXT(PRIsLPOLESTR) TEXT(" to \"%s\" failed (error 0x%x).\n"), szAdapterId, szName, dwResult); + _ftprintf(stderr, TEXT("Renaming TUN/TAP adapter %") TEXT(PRIsLPOLESTR) + TEXT(" to \"%") TEXT(PRIsLPTSTR) TEXT("\" failed (error 0x%x).\n"), + szAdapterId, szName, dwResult); CoTaskMemFree(szAdapterId); iResult = 1; goto quit; } @@ -289,7 +295,9 @@ create_delete_adapter: } else { - _ftprintf(stderr, TEXT("Unknown option \"%s\". Please, use \"tapctl help list\" to list supported options. Ignored.\n"), argv[i]); + _ftprintf(stderr, TEXT("Unknown option \"%") TEXT(PRIsLPTSTR) + TEXT("\". Please, use \"tapctl help list\" to list supported options. Ignored.\n"), + argv[i]); } } @@ -306,7 +314,8 @@ create_delete_adapter: { LPOLESTR szAdapterId = NULL; StringFromIID((REFIID)&pAdapter->guid, &szAdapterId); - _ftprintf(stdout, TEXT("%") TEXT(PRIsLPOLESTR) TEXT("\t%") TEXT(PRIsLPTSTR) TEXT("\n"), szAdapterId, pAdapter->szName); + _ftprintf(stdout, TEXT("%") TEXT(PRIsLPOLESTR) TEXT("\t%") + TEXT(PRIsLPTSTR) TEXT("\n"), szAdapterId, pAdapter->szName); CoTaskMemFree(szAdapterId); } @@ -337,7 +346,7 @@ create_delete_adapter: { if (pAdapter == NULL) { - _ftprintf(stderr, TEXT("\"%s\" adapter not found.\n"), argv[2]); + _ftprintf(stderr, TEXT("\"%") TEXT(PRIsLPTSTR) TEXT("\" adapter not found.\n"), argv[2]); iResult = 1; goto delete_cleanup_pAdapterList; } else if (_tcsicmp(argv[2], pAdapter->szName) == 0) @@ -364,7 +373,8 @@ delete_cleanup_pAdapterList: &bRebootRequired); if (dwResult != ERROR_SUCCESS) { - _ftprintf(stderr, TEXT("Deleting adapter \"%s\" failed (error 0x%x).\n"), argv[2], dwResult); + _ftprintf(stderr, TEXT("Deleting adapter \"%") TEXT(PRIsLPTSTR) + TEXT("\" failed (error 0x%x).\n"), argv[2], dwResult); iResult = 1; goto quit; } @@ -372,7 +382,8 @@ delete_cleanup_pAdapterList: } else { - _ftprintf(stderr, TEXT("Unknown command \"%s\". Please, use \"tapctl help\" to list supported commands.\n"), argv[1]); + _ftprintf(stderr, TEXT("Unknown command \"%") TEXT(PRIsLPTSTR) + TEXT("\". Please, use \"tapctl help\" to list supported commands.\n"), argv[1]); return 1; } @@ -434,7 +445,7 @@ x_msg_va(const unsigned int flags, const char *format, va_list arglist) } /* Output error message. */ - _ftprintf(stderr, TEXT("Error 0x%x: %s\n"), dwResult, szErrMessage); + _ftprintf(stderr, TEXT("Error 0x%x: %") TEXT(PRIsLPTSTR) TEXT("\n"), dwResult, szErrMessage); LocalFree(szErrMessage); } diff --git a/src/tapctl/tap.c b/src/tapctl/tap.c index 563c07f6..b8d63b0f 100644 --- a/src/tapctl/tap.c +++ b/src/tapctl/tap.c @@ -1117,7 +1117,8 @@ tap_set_adapter_name( } /* rename adapter via netsh call */ - const TCHAR* szFmt = _T("netsh interface set interface name=\"%s\" newname=\"%s\""); + const TCHAR* szFmt = TEXT("netsh interface set interface name=\"%") + TEXT(PRIsLPTSTR) TEXT("\" newname=\"%") TEXT(PRIsLPTSTR) TEXT("\""); size_t ncmdline = _tcslen(szFmt) + _tcslen(szOldName) + _tcslen(szName) + 1; WCHAR* szCmdLine = malloc(ncmdline * sizeof(TCHAR)); _stprintf_s(szCmdLine, ncmdline, szFmt, szOldName, szName);