mirror of
https://github.com/samba-team/samba.git
synced 2025-02-03 13:47:25 +03:00
fixed our smbsearch code. We now store the mask with the dptr, this
turns out to be essential for a correct implementation (there ins't enough room to store all possible masks in the status return structure!) (This used to be commit 38f5e133670ada6e5799a16cf1a0e2e3ee1d9afd)
This commit is contained in:
parent
565cc66e6a
commit
34cd425c1d
@ -591,7 +591,6 @@ BOOL get_dir_entry(connection_struct *conn,char *mask,int dirtype,char *fname,
|
||||
|
||||
while (!found)
|
||||
{
|
||||
BOOL filename_is_mask = False;
|
||||
dname = ReadDirName(conn->dirptr);
|
||||
|
||||
DEBUG(6,("readdir on dirptr 0x%lx now at offset %d\n",
|
||||
@ -602,13 +601,22 @@ BOOL get_dir_entry(connection_struct *conn,char *mask,int dirtype,char *fname,
|
||||
|
||||
pstrcpy(filename,dname);
|
||||
|
||||
if ((filename_is_mask = (strcmp(filename,mask) == 0)) ||
|
||||
/* notice the special *.* handling. This appears to be the only difference
|
||||
between the wildcard handling in this routine and in the trans2 routines.
|
||||
see masktest for a demo
|
||||
*/
|
||||
if ((strcmp(mask,"*.*") == 0) ||
|
||||
mask_match(filename,mask,False) ||
|
||||
(name_map_mangle(filename,True,False,SNUM(conn)) &&
|
||||
mask_match(filename,mask,False)))
|
||||
{
|
||||
if (isrootdir && (strequal(filename,"..") || strequal(filename,".")))
|
||||
continue;
|
||||
|
||||
if (!is_8_3(filename, False)) {
|
||||
name_map_mangle(filename,True,False,SNUM(conn));
|
||||
}
|
||||
|
||||
pstrcpy(fname,filename);
|
||||
*path = 0;
|
||||
pstrcpy(path,conn->dirpath);
|
||||
@ -631,17 +639,10 @@ BOOL get_dir_entry(connection_struct *conn,char *mask,int dirtype,char *fname,
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!filename_is_mask)
|
||||
{
|
||||
/* Now we can allow the mangled cache to be updated */
|
||||
pstrcpy(filename,dname);
|
||||
name_map_mangle(filename,True,True,SNUM(conn));
|
||||
}
|
||||
|
||||
*size = sbuf.st_size;
|
||||
*date = sbuf.st_mtime;
|
||||
|
||||
DEBUG(5,("get_dir_entry found %s fname=%s\n",pathreal,fname));
|
||||
DEBUG(0,("get_dir_entry mask=[%s] found %s fname=%s\n",mask, pathreal,fname));
|
||||
|
||||
found = True;
|
||||
}
|
||||
|
@ -1265,9 +1265,6 @@ int reply_search(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
|
||||
|
||||
/* dirtype &= ~aDIR; */
|
||||
|
||||
DEBUG(5,("reply_search: path=%s status_len=%d\n",path,status_len));
|
||||
|
||||
|
||||
if (status_len == 0)
|
||||
{
|
||||
pstring dir2;
|
||||
@ -1306,15 +1303,12 @@ int reply_search(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
|
||||
else
|
||||
{
|
||||
memcpy(status,smb_buf(inbuf) + 1 + strlen(path) + 4,21);
|
||||
memcpy(mask,status+1,11);
|
||||
mask[11] = 0;
|
||||
dirtype = CVAL(status,0) & 0x1F;
|
||||
conn->dirptr = dptr_fetch(status+12,&dptr_num);
|
||||
if (!conn->dirptr)
|
||||
goto SearchEmpty;
|
||||
string_set(&conn->dirpath,dptr_path(dptr_num));
|
||||
if (!case_sensitive)
|
||||
strnorm(mask);
|
||||
fstrcpy(mask, dptr_wcard(dptr_num));
|
||||
}
|
||||
|
||||
/* turn strings of spaces into a . */
|
||||
@ -1326,8 +1320,10 @@ int reply_search(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
|
||||
fstrcpy(ext,p+1);
|
||||
*p = 0;
|
||||
trim_string(mask,NULL," ");
|
||||
pstrcat(mask,".");
|
||||
pstrcat(mask,ext);
|
||||
if (ext[0]) {
|
||||
pstrcat(mask,".");
|
||||
pstrcat(mask,ext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1352,17 +1348,6 @@ int reply_search(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
|
||||
}
|
||||
}
|
||||
|
||||
if (!strchr(mask,'.') && strlen(mask)>8)
|
||||
{
|
||||
fstring tmp;
|
||||
fstrcpy(tmp,&mask[8]);
|
||||
mask[8] = '.';
|
||||
mask[9] = 0;
|
||||
pstrcat(mask,tmp);
|
||||
}
|
||||
|
||||
DEBUG(5,("mask=%s directory=%s\n",mask,directory));
|
||||
|
||||
if (can_open)
|
||||
{
|
||||
p = smb_buf(outbuf) + 3;
|
||||
@ -1385,6 +1370,7 @@ int reply_search(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
|
||||
}
|
||||
return(ERROR(ERRDOS,ERRnofids));
|
||||
}
|
||||
dptr_set_wcard(dptr_num, mask);
|
||||
}
|
||||
|
||||
DEBUG(4,("dptr_num is %d\n",dptr_num));
|
||||
@ -1419,8 +1405,8 @@ int reply_search(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
|
||||
make_dir_struct(p,mask,fname,size,mode,date);
|
||||
dptr_fill(p+12,dptr_num);
|
||||
numentries++;
|
||||
}
|
||||
p += DIR_STRUCT_SIZE;
|
||||
}
|
||||
p += DIR_STRUCT_SIZE;
|
||||
}
|
||||
}
|
||||
} /* if (ok ) */
|
||||
|
Loading…
x
Reference in New Issue
Block a user