[Openvpn-devel,OpenVPN3,1/2] ovpnagent: fix quoting of omiclient parameters

Message ID 20220607163049.10056-1-facboy@gmail.com
State Accepted, archived
Delegated to: David Sommerseth
Headers show
Series [Openvpn-devel,OpenVPN3,1/2] ovpnagent: fix quoting of omiclient parameters | expand

Commit Message

Christopher Ng June 7, 2022, 6:30 a.m. UTC
Signed-off-by: Christopher Ng <facboy@gmail.com>
---
 openvpn/ovpnagent/win/ovpnagent.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Lev Stipakov June 7, 2022, 8:37 p.m. UTC | #1
As per discussion on https://github.com/OpenVPN/openvpn3/pull/218

Acked-by: Lev Stipakov <lstipakov@gmail.com>

ti 7. kesäk. 2022 klo 20.30 Christopher Ng (facboy@gmail.com) kirjoitti:

> Signed-off-by: Christopher Ng <facboy@gmail.com>
> ---
>  openvpn/ovpnagent/win/ovpnagent.cpp | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/openvpn/ovpnagent/win/ovpnagent.cpp
> b/openvpn/ovpnagent/win/ovpnagent.cpp
> index 8a31b0aa..fa020e7d 100644
> --- a/openvpn/ovpnagent/win/ovpnagent.cpp
> +++ b/openvpn/ovpnagent/win/ovpnagent.cpp
> @@ -444,14 +444,16 @@ public:
>
>        // create command line for openvpn process
>        std::ostringstream ss;
> -      ss << "client --config " << config_dir << "\\" << config_file << "
> --exit-event-name "
> +      ss << "client --config \"" << config_dir << "\\" << config_file <<
> "\" --exit-event-name "
>          << exit_event_name << " --auth-retry interact --management " <<
> management_host << " "
>          << management_port << " stdin --management-query-passwords
> --management-hold " << "--log"
> -        << (log_append ? "-append " : " ") << log;
> +        << (log_append ? "-append \"" : " \"") << log << "\"";
>        std::string cmd = ss.str();
>        std::unique_ptr<char[]> buf(new char[cmd.length() + 1]);
>        strcpy(buf.get(), cmd.c_str());
>
> +      // OPENVPN_LOG("Launching omiclient: " <<
> config.omiclient_exe.c_str() << " " << buf.get());
> +
>        STARTUPINFO startup_info = { 0 };
>        startup_info.cb = sizeof(startup_info);
>        startup_info.dwFlags = STARTF_USESTDHANDLES;
> --
> 2.34.1
>
>
>
> _______________________________________________
> Openvpn-devel mailing list
> Openvpn-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/openvpn-devel
>
David Sommerseth June 8, 2022, 1:53 p.m. UTC | #2
From: David Sommerseth <davids@openvpn.net>

Your patch has been applied to the master branch

commit 452e7cb6259d40ae0a1ff749d22a1634c7100fc9 master
Author: Christopher Ng
Date:   Tue, 07 Jun 2022 16:30:48 +0000

     ovpnagent: fix quoting of omiclient parameters

     Signed-off-by: Christopher Ng
     Acked-by: Lev Stipakov
     Patchwork-Id: 2510
     URL: https://patchwork.openvpn.net/patch/2510/
     Message-Id: <20220607163049.10056-1-facboy@gmail.com>
     Signed-off-by: David Sommerseth


--
kind regards,

David Sommerseth

Patch

diff --git a/openvpn/ovpnagent/win/ovpnagent.cpp b/openvpn/ovpnagent/win/ovpnagent.cpp
index 8a31b0aa..fa020e7d 100644
--- a/openvpn/ovpnagent/win/ovpnagent.cpp
+++ b/openvpn/ovpnagent/win/ovpnagent.cpp
@@ -444,14 +444,16 @@  public:
 
       // create command line for openvpn process
       std::ostringstream ss;
-      ss << "client --config " << config_dir << "\\" << config_file << " --exit-event-name "
+      ss << "client --config \"" << config_dir << "\\" << config_file << "\" --exit-event-name "
 	 << exit_event_name << " --auth-retry interact --management " << management_host << " "
 	 << management_port << " stdin --management-query-passwords --management-hold " << "--log"
-	 << (log_append ? "-append " : " ") << log;
+	 << (log_append ? "-append \"" : " \"") << log << "\"";
       std::string cmd = ss.str();
       std::unique_ptr<char[]> buf(new char[cmd.length() + 1]);
       strcpy(buf.get(), cmd.c_str());
 
+      // OPENVPN_LOG("Launching omiclient: " << config.omiclient_exe.c_str() << " " << buf.get());
+
       STARTUPINFO startup_info = { 0 };
       startup_info.cb = sizeof(startup_info);
       startup_info.dwFlags = STARTF_USESTDHANDLES;