summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Bokovoy <ab@samba.org>2004-03-16 17:21:06 +0000
committerAlexander Bokovoy <ab@samba.org>2004-03-16 17:21:06 +0000
commitba042a96cdb8e4b12791481725fbbf193df130b7 (patch)
tree4847c131a2794f9dab3b54c504f6c567f9126e90
parentb1d5261bde86abdd90701897ebc2d03211b65c33 (diff)
downloadsamba-ba042a96cdb8e4b12791481725fbbf193df130b7.tar.gz
samba-ba042a96cdb8e4b12791481725fbbf193df130b7.tar.bz2
samba-ba042a96cdb8e4b12791481725fbbf193df130b7.zip
Fix check_path_syntax() for multibyte encodings which have no '\' as second byte.
This is intermediate fix as discussed with Jeremy until we move check_path_syntax() to UCS2 internally where all ambiguity is resolved. Please add other encodings into charcnv.c with such property. (This used to be commit c8c66337494c63173a6aba4286a843875302da63)
-rw-r--r--source3/lib/charcnv.c20
-rw-r--r--source3/smbd/reply.c4
2 files changed, 23 insertions, 1 deletions
diff --git a/source3/lib/charcnv.c b/source3/lib/charcnv.c
index 20af806d90..b06d869bcc 100644
--- a/source3/lib/charcnv.c
+++ b/source3/lib/charcnv.c
@@ -41,6 +41,15 @@
static smb_iconv_t conv_handles[NUM_CHARSETS][NUM_CHARSETS];
static BOOL conv_silent; /* Should we do a debug if the conversion fails ? */
+/* Unsafe unix charsets which could contain '\\' as second byte of mb character */
+static const char *conv_unsafe_charsets[] = {
+ "CP932",
+ "EUC-JP",
+ NULL};
+/* Global variable which is set to True in init_iconv() if unix charset is unsafe
+ w.r.t. '\\' in second byte of mb character. Otherwise it is set to False.
+*/
+BOOL is_unix_charset_unsafe;
/**
* Return the name of a charset to give to iconv().
@@ -105,6 +114,7 @@ void init_iconv(void)
{
int c1, c2;
BOOL did_reload = False;
+ const char **unsafe_charset = conv_unsafe_charsets;
/* so that charset_name() works we need to get the UNIX<->UCS2 going
first */
@@ -146,6 +156,16 @@ void init_iconv(void)
init_valid_table();
conv_silent = False;
}
+
+ while(*unsafe_charset && strcmp(*unsafe_charset, conv_handles[CH_UCS2][CH_UNIX]->to_name)) {
+ unsafe_charset++;
+ }
+
+ if (*unsafe_charset) {
+ is_unix_charset_unsafe = True;
+ } else {
+ is_unix_charset_unsafe = False;
+ }
}
/**
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index bca7a75fbb..48894308d1 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -33,6 +33,7 @@ extern char magic_char;
extern BOOL case_sensitive;
extern BOOL case_preserve;
extern BOOL short_case_preserve;
+extern BOOL is_unix_charset_unsafe;
extern int global_oplock_break;
unsigned int smb_echo_count = 0;
@@ -110,7 +111,8 @@ NTSTATUS check_path_syntax(pstring destname, const pstring srcname)
}
s++;
} else {
- if ((*s & 0x80) && IS_DIRECTORY_SEP(s[1])) {
+ /* Activate this codepath only if we know that Unix charset may contain unsafe '\\' */
+ if ((is_unix_charset_unsafe == True) && ((*s & 0x80) && IS_DIRECTORY_SEP(s[1]))) {
/*
* Potential mb char with second char a directory separator.
* All the encodings we care about are 2 byte only, so do a