diff options
Diffstat (limited to 'source3/smbd/trans2.c')
-rw-r--r-- | source3/smbd/trans2.c | 67 |
1 files changed, 29 insertions, 38 deletions
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index 4e502f767b..7ae24f9e38 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -287,6 +287,19 @@ static int call_trans2open(connection_struct *conn, char *inbuf, char *outbuf, return -1; } +/********************************************************* +* Routine to check if a given string matches exactly. +* as a special case a mask of "." does NOT match. That +* is required for correct wildcard semantics +* Case can be significant or not. +**********************************************************/ +static BOOL exact_match(char *str,char *mask, BOOL case_sig) +{ + if (mask[0] == '.' && mask[1] == 0) return False; + if (case_sig) return strcmp(str,mask)==0; + return strcasecmp(str,mask) == 0; +} + /**************************************************************************** get a level dependent lanman2 dir entry. ****************************************************************************/ @@ -360,7 +373,7 @@ static BOOL get_lanman2_dir_entry(connection_struct *conn, pstrcpy(fname,dname); if(!(got_match = *got_exact_match = exact_match(fname, mask, case_sensitive))) - got_match = mask_match(fname, mask, case_sensitive, True); + got_match = mask_match(fname, mask, case_sensitive); if(!got_match && !is_8_3(fname, False)) { @@ -375,7 +388,7 @@ static BOOL get_lanman2_dir_entry(connection_struct *conn, pstrcpy( newname, fname); name_map_mangle( newname, True, False, SNUM(conn)); if(!(got_match = *got_exact_match = exact_match(newname, mask, case_sensitive))) - got_match = mask_match(newname, mask, case_sensitive, True); + got_match = mask_match(newname, mask, case_sensitive); } if(got_match) @@ -509,13 +522,20 @@ static BOOL get_lanman2_dir_entry(connection_struct *conn, SIVAL(p,0,strlen(fname)); p += 4; SIVAL(p,0,0); p += 4; if (!was_8_3) { - pstrcpy(p+2,fname); - if (!name_map_mangle(p+2,True,True,SNUM(conn))) - (p+2)[12] = 0; - } else - *(p+2) = 0; - strupper(p+2); - SSVAL(p,0,strlen(p+2)); + /* NT4 always uses unicode here */ + fstring short_name, ushort_name; + int slen; + pstrcpy(short_name,fname); + name_map_mangle(short_name,True,True,SNUM(conn)); + strupper(short_name); + slen = strlen(short_name); + ascii_to_unistr(ushort_name, short_name, 24); + memcpy(p+2, ushort_name, 2*slen); + SSVAL(p, 0, 2*slen); + } else { + SSVAL(p,0,0); + *(p+2) = 0; + } p += 2 + 24; /* nameptr = p; */ pstrcpy(p,fname); p += strlen(p); @@ -591,32 +611,6 @@ static BOOL get_lanman2_dir_entry(connection_struct *conn, return(found); } -/**************************************************************************** - Convert the directory masks formated for the wire. -****************************************************************************/ - -void mask_convert( char *mask) -{ - /* - * We know mask is a pstring. - */ - char *p = mask; - while (*p) { - if (*p == '<') { - pstring expnd; - if(p[1] != '"' && p[1] != '.') { - pstrcpy( expnd, p+1 ); - *p++ = '*'; - *p = '.'; - safe_strcpy( p+1, expnd, sizeof(pstring) - (p - mask) - 2); - } else - *p = '*'; - } - if (*p == '>') *p = '?'; - if (*p == '"') *p = '.'; - p++; - } -} /**************************************************************************** Reply to a TRANS2_FINDFIRST. @@ -727,9 +721,6 @@ static int call_trans2findfirst(connection_struct *conn, if (dptr_num < 0) return(UNIXERROR(ERRDOS,ERRbadfile)); - /* Convert the formatted mask. */ - mask_convert(mask); - /* Save the wildcard match and attribs we are using on this directory - needed as lanman2 assumes these are being saved between calls */ |