From patchwork Fri Oct 10 09:47:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 4494 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:7d42:b0:72f:f16c:e055 with SMTP id fr2csp173150mab; Fri, 10 Oct 2025 02:48:13 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWlmjcAfBbiBU/R7rUBKDjRIuI+tImbPe/Nb8RjeZQtcHoDkh3qrQr5qflIAN+GmAkltQlb5vKUbKo=@openvpn.net X-Google-Smtp-Source: AGHT+IFR/z0ge/lO/4+Tk0D/YEaxZyHkDQ8GUxngmdY5JlREX1i+jt7Jdt4S1nqMndIeECJtSlc9 X-Received: by 2002:a05:6830:6286:b0:745:6503:a594 with SMTP id 46e09a7af769-7c0df785257mr7940636a34.12.1760089692960; Fri, 10 Oct 2025 02:48:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1760089692; cv=none; d=google.com; s=arc-20240605; b=C5rdgb48AnnJz0hMd9dNy4la05wv/sldKGPVUF0ZwKWcRIlViYxbrdJiQdlSMZfScb HgOnFYxWWcHPZq8acAK/25UJFsmoFg2NFGW5xh4OvLoJLvEHAMt9qmn2fJoulywgVz6L MVlvZ7LPPtZnB1YP4wlB/WWRlbv9kn77v/tSy0+m7SZtiySqRJPM/0G48XEFKbbDWKMh t+uImvX9k27tqsVe0Pxlo18VedCceSBbaPVxdwJgxFduEy9YL2HKZVJOnX220qfEoEan nu64QHWKoKTP/bS/BOMAauUtXcN3NVPxT2h0UjPNBnPX2OtRhLzItXNmPqhj4pdqb4So Wmng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:dkim-signature:dkim-signature; bh=q8yr2NB2l28DtFHzzL+3/4quOCy8R3nIVQ9D7pJ6iPM=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=VNBfAwb7ftpPD6uOALfT1yw3q/kyGJFu+puXWvqQ3UnjszamQ0zPziWmXWYD9BgX2t 2k6DpGhYtSrkMW58I7Yk0guqdHNR9+sP7EmxoQ2ao/PYe91QeXpzSIt3xhyZ24bP/Yrm b65aNWEFWX54N4zjfd+8iKKohpF7RQF6wR6i+tngs1+htYqZkGvhvtD0v1hnobYhnPyq K6g8zpgysTZz/xLhkZZ5+hPq51Qf3wiOhl3r8zDad5H2SNZNnIyE1ah/wwyUDjXsrjft vdWg8JYQbphu4pJPvYUE+nVDjgWpiULHW92DC8zPhoq84f1bPKi0CSMM+nSzu938M62i R/+Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=dvIwVXW6; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=TK6v1NbN; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=Kmtntyxd; 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=NONE dis=NONE) header.from=muc.de Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id 46e09a7af769-7c0f8fc27b4si439267a34.90.2025.10.10.02.48.12 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Oct 2025 02:48:12 -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=pass header.i=@lists.sourceforge.net header.s=beta header.b=dvIwVXW6; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=TK6v1NbN; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=Kmtntyxd; 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=NONE dis=NONE) header.from=muc.de DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Subject:MIME-Version:References:In-Reply-To:Message-ID:Date:To:From:Sender: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=q8yr2NB2l28DtFHzzL+3/4quOCy8R3nIVQ9D7pJ6iPM=; b=dvIwVXW6INvBFBAOzMl6MSTzmT IiH267GzUhZqfuFWDZkrLsOPv0UmKNkCPsDSB3/RLnLPYpxnnR17lhfx0GycU1DYn6V0C3Njq1e7N 6YqYHUd5AMeNVe/oKhOwWzaSvpxtci16FOy/79J/OQeRvpJnbjkhRl46m4W67clq8Ijg=; 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 1v79jN-0000ty-9Q; Fri, 10 Oct 2025 09:48:09 +0000 Received: from [172.30.29.66] (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 1v79jL-0000tn-P6 for openvpn-devel@lists.sourceforge.net; Fri, 10 Oct 2025 09:48: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:To:From:Sender:Reply-To:Cc: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=liA1F31QXB2CKJHO5LjLQWTl4vaexKieyDSgaGZ5qJM=; b=TK6v1NbNUt09dXHXS3FSyeHGt9 Dl6oS/t+yxgM0VtREqWxoxV5WQMKDUOWd8doOGTS4Kpoho3QjUWLecy1bOvgjVOEx+dvGxkEFSrkP rY7hRRnVEFA5Cjll3JFqdjktbi8WnEbhF0GyDRvhKnwVLR4X9t4VOqwIqu57TEJhEJR0=; 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:To:From:Sender:Reply-To:Cc: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=liA1F31QXB2CKJHO5LjLQWTl4vaexKieyDSgaGZ5qJM=; b=KmtntyxdmeXJa53IAsIqTL1RMH 4ZkKP6ONwvZJya4FKOXVBxDp61+gKsXu7+oWuCsgsBl5c4+EPX77hHK6R6Z6CFUVXcdhucESegJVU 1sE864hQs5GceL56PTtEBS5ueDryYKmrvXTfPIiKwp8UgFxHpOVvJ84rnYOQnLsD7GNE=; Received: from [193.149.48.134] (helo=blue.greenie.muc.de) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1v79jK-0003aw-Dk for openvpn-devel@lists.sourceforge.net; Fri, 10 Oct 2025 09:48:07 +0000 Received: from blue.greenie.muc.de (localhost [127.0.0.1]) by blue.greenie.muc.de (8.18.1/8.18.1) with ESMTP id 59A9lsWg002851 for ; Fri, 10 Oct 2025 11:47:54 +0200 Received: (from gert@localhost) by blue.greenie.muc.de (8.18.1/8.18.1/Submit) id 59A9lsi0002850 for openvpn-devel@lists.sourceforge.net; Fri, 10 Oct 2025 11:47:54 +0200 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Fri, 10 Oct 2025 11:47:44 +0200 Message-ID: <20251010094753.2825-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.49.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Score: 1.3 (+) X-Spam-Report: Spam detection software, running on the system "sfi-spamd-1.hosts.colo.sdot.me", 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: Frank Lichtenheld - Removes unused field prompt_len - Change field reponse_len to int since that is what the code actually expects. Most callers user a constant either way. Content analysis details: (1.3 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.3 RDNS_NONE Delivered to internal network by a host with no rDNS X-Headers-End: 1v79jK-0003aw-Dk Subject: [Openvpn-devel] [PATCH v5] console: Simplify query_user_add interface 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?1845587809831067628?= X-GMAIL-MSGID: =?utf-8?q?1845587809831067628?= From: Frank Lichtenheld - Removes unused field prompt_len - Change field reponse_len to int since that is what the code actually expects. Most callers user a constant either way. Change-Id: I04542e678f81d5d4a853b4370d9b8adc4dac1212 Signed-off-by: Frank Lichtenheld Acked-by: Gert Doering Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1216 --- This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master. Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1216 This mail reflects revision 5 of this Change. Acked-by according to Gerrit (reflected above): Gert Doering diff --git a/src/openvpn/console.c b/src/openvpn/console.c index bdceaf2..3cb23b3 100644 --- a/src/openvpn/console.c +++ b/src/openvpn/console.c @@ -53,14 +53,14 @@ void -query_user_add(char *prompt, size_t prompt_len, char *resp, size_t resp_len, bool echo) +query_user_add(char *prompt, char *resp, int resp_len, bool echo) { int i; /* Ensure input is sane. All these must be present otherwise it is * a programming error. */ - ASSERT(prompt_len > 0 && prompt != NULL && resp_len > 0 && resp != NULL); + ASSERT(prompt != NULL && resp_len > 0 && resp != NULL); /* Seek to the last unused slot */ for (i = 0; i < QUERY_USER_NUMSLOTS; i++) @@ -74,7 +74,6 @@ /* Save the information needed for the user interaction */ query_user[i].prompt = prompt; - query_user[i].prompt_len = prompt_len; query_user[i].response = resp; query_user[i].response_len = resp_len; query_user[i].echo = echo; diff --git a/src/openvpn/console.h b/src/openvpn/console.h index 14b6116..fba2a09 100644 --- a/src/openvpn/console.h +++ b/src/openvpn/console.h @@ -32,11 +32,10 @@ */ struct _query_user { - char *prompt; /**< Prompt to present to the user */ - size_t prompt_len; /**< Length of the prompt string */ - char *response; /**< The user's response */ - size_t response_len; /**< Length the of the user response */ - bool echo; /**< True: The user should see what is being typed, otherwise mask it */ + char *prompt; /**< Prompt to present to the user */ + char *response; /**< The user's response */ + int response_len; /**< Length the of the user response */ + bool echo; /**< True: The user should see what is being typed, otherwise mask it */ }; #define QUERY_USER_NUMSLOTS 10 @@ -53,13 +52,12 @@ * Adds an item to ask the user for * * @param prompt Prompt to display to the user - * @param prompt_len Length of the prompt string * @param resp String containing the user response * @param resp_len Length of the response string * @param echo Should the user input be echoed to the user? If False, input will be masked * */ -void query_user_add(char *prompt, size_t prompt_len, char *resp, size_t resp_len, bool echo); +void query_user_add(char *prompt, char *resp, int resp_len, bool echo); /** @@ -117,10 +115,10 @@ * */ static inline bool -query_user_SINGLE(char *prompt, size_t prompt_len, char *resp, size_t resp_len, bool echo) +query_user_SINGLE(char *prompt, char *resp, int resp_len, bool echo) { query_user_clear(); - query_user_add(prompt, prompt_len, resp, resp_len, echo); + query_user_add(prompt, resp, resp_len, echo); return query_user_exec(); } diff --git a/src/openvpn/console_builtin.c b/src/openvpn/console_builtin.c index 71c0025..2a925d6 100644 --- a/src/openvpn/console_builtin.c +++ b/src/openvpn/console_builtin.c @@ -45,11 +45,6 @@ #include "win32.h" -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - /** * Get input from a Windows console. * @@ -73,7 +68,7 @@ HANDLE in = GetStdHandle(STD_INPUT_HANDLE); int orig_stderr = get_orig_stderr(); /* guaranteed to be always valid */ if ((in == INVALID_HANDLE_VALUE) || win32_service_interrupt(&win32_signal) - || (_write(orig_stderr, prompt, strlen(prompt)) == -1)) + || (_write(orig_stderr, prompt, (unsigned int)strlen(prompt)) == -1)) { msg(M_WARN | M_ERRNO, "get_console_input_win32(): unexpected error"); return false; @@ -139,10 +134,6 @@ return false; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - #endif /* _WIN32 */ @@ -273,11 +264,6 @@ return ret; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - /** * @copydoc query_user_exec() * @@ -309,7 +295,3 @@ return ret; } - -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif diff --git a/src/openvpn/misc.c b/src/openvpn/misc.c index caf4725..188f44e 100644 --- a/src/openvpn/misc.c +++ b/src/openvpn/misc.c @@ -239,8 +239,7 @@ struct buffer user_prompt = alloc_buf_gc(128, &gc); buf_printf(&user_prompt, "NEED-OK|%s|%s:", prefix, up->username); - if (!query_user_SINGLE(BSTR(&user_prompt), BLEN(&user_prompt), up->password, - USER_PASS_LEN, false)) + if (!query_user_SINGLE(BSTR(&user_prompt), up->password, USER_PASS_LEN, false)) { msg(M_FATAL, "ERROR: could not read %s ok-confirmation from stdin", prefix); } @@ -362,7 +361,7 @@ buf_printf(&challenge, "CHALLENGE: %s", ac->challenge_text); buf_set_write(&packed_resp, (uint8_t *)up->password, USER_PASS_LEN); - if (!query_user_SINGLE(BSTR(&challenge), BLEN(&challenge), response, + if (!query_user_SINGLE(BSTR(&challenge), response, USER_PASS_LEN, BOOL_CAST(ac->flags & CR_ECHO))) { msg(M_FATAL, "ERROR: could not read challenge response from stdin"); @@ -387,14 +386,12 @@ if (username_from_stdin && !(flags & GET_USER_PASS_PASSWORD_ONLY)) { - query_user_add(BSTR(&user_prompt), BLEN(&user_prompt), up->username, - USER_PASS_LEN, true); + query_user_add(BSTR(&user_prompt), up->username, USER_PASS_LEN, true); } if (password_from_stdin) { - query_user_add(BSTR(&pass_prompt), BLEN(&pass_prompt), up->password, - USER_PASS_LEN, false); + query_user_add(BSTR(&pass_prompt), up->password, USER_PASS_LEN, false); } if (!query_user_exec()) @@ -421,8 +418,7 @@ challenge = alloc_buf_gc(14 + strlen(auth_challenge), &gc); buf_printf(&challenge, "CHALLENGE: %s", auth_challenge); - if (!query_user_SINGLE(BSTR(&challenge), BLEN(&challenge), response, - USER_PASS_LEN, + if (!query_user_SINGLE(BSTR(&challenge), response, USER_PASS_LEN, BOOL_CAST(flags & GET_USER_PASS_STATIC_CHALLENGE_ECHO))) { msg(M_FATAL, "ERROR: could not retrieve static challenge response"); diff --git a/src/openvpn/pkcs11.c b/src/openvpn/pkcs11.c index 16149ca..ce64135 100644 --- a/src/openvpn/pkcs11.c +++ b/src/openvpn/pkcs11.c @@ -671,7 +671,7 @@ ASSERT(token != NULL); buf_printf(&pass_prompt, "Please enter '%s' token PIN or 'cancel': ", token->display); - if (!query_user_SINGLE(BSTR(&pass_prompt), BLEN(&pass_prompt), pin, pin_max, false)) + if (!query_user_SINGLE(BSTR(&pass_prompt), pin, (int)pin_max, false)) { msg(M_FATAL, "Could not retrieve the PIN"); }