Attention is currently required from: d12fk, flichtenheld, plaisthos, stipa.

Hello flichtenheld, plaisthos, stipa,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1336?usp=email

to look at the new patch set (#3).

The following approvals got outdated and were removed:
Code-Review-1 by stipa


Change subject: iservice: make sure directories have trailing \
......................................................................

iservice: make sure directories have trailing \

At least in the case of the config dir this matters, since the value is
used to validate input data for the interactive service. A missing \
at the end would allow a string compare to succeed, if the last element of
the path to compare starts with the same substring. The trailing slash
ensures that the last element of a path must match completely.

Change-Id: If28e66fcc3493821f78fd14d432b22b996918e8f
Signed-off-by: Heiko Hund <[email protected]>
---
M src/openvpnserv/common.c
1 file changed, 24 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/36/1336/3

diff --git a/src/openvpnserv/common.c b/src/openvpnserv/common.c
index d25d9c0..b2225f8 100644
--- a/src/openvpnserv/common.c
+++ b/src/openvpnserv/common.c
@@ -20,6 +20,8 @@
  *  with this program; if not, see <https://www.gnu.org/licenses/>.
  */

+#include <pathcch.h>
+
 #include "service.h"
 #include "validate.h"
 #include "eventmsg.h"
@@ -54,6 +56,22 @@
 }


+/**
+ * Make sure that a dir path ends with a backslash.
+ * If it doesn't, a \ is added to the end of the path, if there's room in the 
buffer.
+ *
+ * @param dir       pointer to the wide dir path string buffer
+ * @param size      maximum number of wide chars the dir path buffer
+ * @return BOOL to indicate success or failure
+ */
+static BOOL
+ensure_trailing_backslash(PWSTR dir, size_t size)
+{
+    HRESULT res = PathCchAddBackslash(dir, size);
+    return res == S_OK || res == S_FALSE ? TRUE : FALSE;
+}
+
+
 DWORD
 GetOpenvpnSettings(settings_t *s)
 {
@@ -90,16 +108,16 @@
         goto out;
     }

-    swprintf(default_value, _countof(default_value), L"%ls\\config", 
install_path);
+    swprintf(default_value, _countof(default_value), L"%ls\\config\\", 
install_path);
     error = GetRegString(key, L"config_dir", s->config_dir, 
sizeof(s->config_dir), default_value);
-    if (error != ERROR_SUCCESS)
+    if (error != ERROR_SUCCESS || !ensure_trailing_backslash(s->config_dir, 
_countof(s->config_dir)))
     {
         goto out;
     }

-    swprintf(default_value, _countof(default_value), L"%ls\\bin", 
install_path);
+    swprintf(default_value, _countof(default_value), L"%ls\\bin\\", 
install_path);
     error = GetRegString(key, L"bin_dir", s->bin_dir, sizeof(s->bin_dir), 
default_value);
-    if (error != ERROR_SUCCESS)
+    if (error != ERROR_SUCCESS || !ensure_trailing_backslash(s->bin_dir, 
_countof(s->bin_dir)))
     {
         goto out;
     }
@@ -110,9 +128,9 @@
         goto out;
     }

-    swprintf(default_value, _countof(default_value), L"%ls\\log", 
install_path);
+    swprintf(default_value, _countof(default_value), L"%ls\\log\\", 
install_path);
     error = GetRegString(key, L"log_dir", s->log_dir, sizeof(s->log_dir), 
default_value);
-    if (error != ERROR_SUCCESS)
+    if (error != ERROR_SUCCESS || !ensure_trailing_backslash(s->log_dir, 
_countof(s->log_dir)))
     {
         goto out;
     }

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1336?usp=email
To unsubscribe, or for help writing mail filters, visit 
http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: If28e66fcc3493821f78fd14d432b22b996918e8f
Gerrit-Change-Number: 1336
Gerrit-PatchSet: 3
Gerrit-Owner: d12fk <[email protected]>
Gerrit-Reviewer: flichtenheld <[email protected]>
Gerrit-Reviewer: plaisthos <[email protected]>
Gerrit-Reviewer: stipa <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]>
Gerrit-Attention: d12fk <[email protected]>
Gerrit-Attention: stipa <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to