summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHeiko Hund <heiko.hund@sophos.com>2012-10-29 14:16:37 +0100
committerDavid Sommerseth <davids@redhat.com>2012-10-29 15:39:40 +0100
commitd442b8dbc4230e4252a63fbd57f149ef3fa090c8 (patch)
treea86f8373e5a50cfbc5ce1a477f0ce45a43515bc4
parent3b8d116d3d9dbe2fac786311db8b2bec53d88c77 (diff)
downloadopenvpn-d442b8dbc4230e4252a63fbd57f149ef3fa090c8.tar.gz
openvpn-d442b8dbc4230e4252a63fbd57f149ef3fa090c8.tar.xz
openvpn-d442b8dbc4230e4252a63fbd57f149ef3fa090c8.zip
Support UTF-8 --client-config-dir
If a common name (or user name, when used in conjunction with --username-as-common-name) contains UTF-8 encoded characters their octets get replaced by underscores. This becomes problematic when user "Müller" and "Möller" need to have a CCD file and both would receive options from the file "M__ller". The situation is even worse for non-latin alphabets, where CCD file names consist of underscores entirely. This patch removes that limitation and also allows the file names to contain any punctuation characters besided the resevered ones. Signed-off-by: Heiko Hund <heiko.hund@sophos.com> Acked-by: David Sommerseth <davids@redhat.com> Message-Id: 1351516597-11128-1-git-send-email-heiko.hund@sophos.com URL: http://article.gmane.org/gmane.network.openvpn.devel/7110 Signed-off-by: David Sommerseth <davids@redhat.com> (cherry picked from commit 9885f57e3ac8d2e32ba20ca84f6bdd0a1a995eac)
-rw-r--r--src/openvpn/buffer.c10
-rw-r--r--src/openvpn/buffer.h5
-rw-r--r--src/openvpn/misc.c8
3 files changed, 22 insertions, 1 deletions
diff --git a/src/openvpn/buffer.c b/src/openvpn/buffer.c
index 5eee3ee..56d14b1 100644
--- a/src/openvpn/buffer.c
+++ b/src/openvpn/buffer.c
@@ -782,6 +782,16 @@ char_class (const unsigned char c, const unsigned int flags)
return true;
if ((flags & CC_EQUAL) && c == '=')
return true;
+ if ((flags & CC_LESS_THAN) && c == '<')
+ return true;
+ if ((flags & CC_GREATER_THAN) && c == '>')
+ return true;
+ if ((flags & CC_PIPE) && c == '|')
+ return true;
+ if ((flags & CC_QUESTION_MARK) && c == '?')
+ return true;
+ if ((flags & CC_ASTERISK) && c == '*')
+ return true;
return false;
}
diff --git a/src/openvpn/buffer.h b/src/openvpn/buffer.h
index 9bc33db..5e11de0 100644
--- a/src/openvpn/buffer.h
+++ b/src/openvpn/buffer.h
@@ -736,6 +736,11 @@ const char *np (const char *str);
#define CC_REVERSE_QUOTE (1<<23)
#define CC_AT (1<<24)
#define CC_EQUAL (1<<25)
+#define CC_LESS_THAN (1<<26)
+#define CC_GREATER_THAN (1<<27)
+#define CC_PIPE (1<<28)
+#define CC_QUESTION_MARK (1<<29)
+#define CC_ASTERISK (1<<30)
/* macro classes */
#define CC_NAME (CC_ALNUM|CC_UNDERBAR)
diff --git a/src/openvpn/misc.c b/src/openvpn/misc.c
index d2882d8..d33db20 100644
--- a/src/openvpn/misc.c
+++ b/src/openvpn/misc.c
@@ -1056,7 +1056,13 @@ hostname_randomize(const char *hostname, struct gc_arena *gc)
const char *
gen_path (const char *directory, const char *filename, struct gc_arena *gc)
{
- const char *safe_filename = string_mod_const (filename, CC_ALNUM|CC_UNDERBAR|CC_DASH|CC_DOT|CC_AT, 0, '_', gc);
+#if WIN32
+ const int CC_PATH_RESERVED = CC_LESS_THAN|CC_GREATER_THAN|CC_COLON|
+ CC_DOUBLE_QUOTE|CC_SLASH|CC_BACKSLASH|CC_PIPE|CC_QUESTION_MARK|CC_ASTERISK;
+#else
+ const int CC_PATH_RESERVED = CC_SLASH;
+#endif
+ const char *safe_filename = string_mod_const (filename, CC_PRINT, CC_PATH_RESERVED, '_', gc);
if (safe_filename
&& strcmp (safe_filename, ".")