Skip to contentSkip to conversation

Windows --up parameter quoting problem

PATCH In review Josh Cepek 3 participants 3 messages Mar 28, 2008 – May 9, 2008

lore
Share & tools
lore

Josh Cepek

author
#0 lore raw

PATCH 1/1 Windows --up parameter quoting problem

Under Windows, when run_up_down() from misc.c executes the --up script, the position of the parameters depends on the device name of the tun/tap adapter. For example, a default installation creates a device that may be called "Local Area Connection 2" (number varies), but this device name isn't quoted when passed to the --up program. This makes determining the actual name (or any other parameters for that matter) nearly impossible.

I've attached a patch that quotes the device argument in the run_up_down() function insuring it is always the first argument to the --up script no matter how many spaces appear in the device name.

Signature · 1 line
Josh
misc.c +2 -2
diff -Naur openvpn-2.1_rc7/misc.c openvpn-2.1_rc7_new/misc.c
@@ -206,7 +206,7 @@
       ASSERT (arg);
 
       buf_printf (&cmd,
-		  "%s %d %d %s %s %s",
+		  "\"%s\" %d %d %s %s %s",
 		  arg,
 		  tun_mtu, link_mtu,
 		  ifconfig_local, ifconfig_remote,
@@ -225,7 +225,7 @@
       setenv_str (es, "script_type", script_type);
 
       buf_printf (&cmd,
-		  "%s %s %d %d %s %s %s",
+		  "%s \"%s\" %d %d %s %s %s",
 		  command,
 		  arg,
 		  tun_mtu, link_mtu,
#1 lore raw

Hello,

You have a valid argument.
I would have suggested to quotes all "%s" arguments of commands, and solve this properly once and for all.

Alon.

Quoted 51 lines · Josh Cepek

Under Windows, when run_up_down() from misc.c executes the --up script,
the position of the parameters depends on the device name of the tun/tap adapter. For example, a default installation creates a device that may be called "Local Area Connection 2" (number varies), but this device name isn't quoted when passed to the --up program. This makes determining the actual name (or any other parameters for that matter) nearly impossible.

I've attached a patch that quotes the device argument in the run_up_down() function insuring it is always the first argument to the --up script no matter how many spaces appear in the device name.

--

Josh

diff -Naur openvpn-2.1_rc7/misc.c openvpn-2.1_rc7_new/misc.c
--- openvpn-2.1_rc7/misc.c 2008-01-23 21:08:41.000000000 +0000
+++ openvpn-2.1_rc7_new/misc.c 2008-03-28 20:34:15.000000000 +0000 @@ -206,7 +206,7 @@

       ASSERT (arg);

       buf_printf (&cmd,
 -                 "%s %d %d %s %s %s",
 +                 "\"%s\" %d %d %s %s %s",
                  arg,
                  tun_mtu, link_mtu,
                  ifconfig_local, ifconfig_remote,
 @@ -225,7 +225,7 @@
       setenv_str (es, "script_type", script_type);

       buf_printf (&cmd,

- "%s %s %d %d %s %s %s",
+ "%s \"%s\" %d %d %s %s %s",
command,
arg,
tun_mtu, link_mtu,

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#2 lore raw
In reply to Josh Cepek
Quoted 5 lines · Josh Cepek

Under Windows, when run_up_down() from misc.c executes the --up script, the position of the parameters depends on the device name of the tun/tap adapter. For example, a default installation creates a device that may be called "Local Area Connection 2" (number varies), but this device name isn't quoted when passed to the --up program. This makes determining the actual name (or any other parameters for that matter) nearly impossible.

I've attached a patch that quotes the device argument in the run_up_down() function insuring it is always the first argument to the --up script no matter how many spaces appear in the device name.

I've merged this patch into the subversion directory for the 2.1 series:

http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn/

It will be included in 2.1-rc8.

James