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().
{
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 */
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;
+ }
}
/**
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;
}
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