summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-01-16 21:04:30 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:17:12 -0500
commit52a36db39fb96353702616dfac5004239c34cd2c (patch)
tree051a00015ec61588588d15f0ee7b702d26057b7b /source3
parentf065b42dcceb4eb64b26921aaa88d7a67bac3dc0 (diff)
downloadsamba-52a36db39fb96353702616dfac5004239c34cd2c.tar.gz
samba-52a36db39fb96353702616dfac5004239c34cd2c.tar.bz2
samba-52a36db39fb96353702616dfac5004239c34cd2c.zip
r20843: Get rid of last BOOL ok.
Jeremy. (This used to be commit a36d446fb612f87654c645f6507d413b95efaf21)
Diffstat (limited to 'source3')
-rw-r--r--source3/smbd/reply.c117
1 files changed, 59 insertions, 58 deletions
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index c90c59698f..9a0e544e38 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -895,14 +895,12 @@ int reply_search(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
unsigned int maxentries = 0;
BOOL finished = False;
char *p;
- BOOL ok = False;
int status_len;
pstring path;
char status[21];
int dptr_num= -1;
BOOL check_descend = False;
BOOL expect_close = False;
- BOOL can_open = True;
NTSTATUS nt_status;
BOOL mask_contains_wcard = False;
BOOL allow_long_path_components = (SVAL(inbuf,smb_flg2) & FLAGS2_LONG_PATH_COMPONENTS) ? True : False;
@@ -917,8 +915,9 @@ int reply_search(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
*mask = *directory = *fname = 0;
/* If we were called as SMBffirst then we must expect close. */
- if(CVAL(inbuf,smb_com) == SMBffirst)
+ if(CVAL(inbuf,smb_com) == SMBffirst) {
expect_close = True;
+ }
outsize = set_message(outbuf,1,3,True);
maxentries = SVAL(inbuf,smb_vwv0);
@@ -951,8 +950,10 @@ int reply_search(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
}
unix_format(dir2);
- if (!check_name(directory,conn))
- can_open = False;
+ if (!check_name(directory,conn)) {
+ END_PROFILE(SMBsearch);
+ return UNIXERROR(ERRDOS, ERRnoaccess);
+ }
p = strrchr_m(dir2,'/');
if (p == NULL) {
@@ -964,13 +965,15 @@ int reply_search(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
}
p = strrchr_m(directory,'/');
- if (!p)
+ if (!p) {
*directory = 0;
- else
+ } else {
*p = 0;
+ }
- if (strlen(directory) == 0)
+ if (strlen(directory) == 0) {
pstrcpy(directory,".");
+ }
memset((char *)status,'\0',21);
SCVAL(status,0,(dirtype & 0x1F));
} else {
@@ -978,83 +981,81 @@ int reply_search(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
memcpy(status,p,21);
status_dirtype = CVAL(status,0) & 0x1F;
- if (status_dirtype != (dirtype & 0x1F))
+ if (status_dirtype != (dirtype & 0x1F)) {
dirtype = status_dirtype;
+ }
conn->dirptr = dptr_fetch(status+12,&dptr_num);
- if (!conn->dirptr)
+ if (!conn->dirptr) {
goto SearchEmpty;
+ }
string_set(&conn->dirpath,dptr_path(dptr_num));
pstrcpy(mask, dptr_wcard(dptr_num));
}
- if (can_open) {
- p = smb_buf(outbuf) + 3;
- ok = True;
+ p = smb_buf(outbuf) + 3;
- if (status_len == 0) {
- dptr_num = dptr_create(conn,directory,True,expect_close,SVAL(inbuf,smb_pid), mask, mask_contains_wcard, dirtype);
- if (dptr_num < 0) {
- if(dptr_num == -2) {
- END_PROFILE(SMBsearch);
- return UNIXERROR(ERRDOS, ERRnofids);
- }
+ if (status_len == 0) {
+ dptr_num = dptr_create(conn,directory,True,expect_close,SVAL(inbuf,smb_pid), mask, mask_contains_wcard, dirtype);
+ if (dptr_num < 0) {
+ if(dptr_num == -2) {
END_PROFILE(SMBsearch);
- return ERROR_DOS(ERRDOS,ERRnofids);
+ return UNIXERROR(ERRDOS, ERRnofids);
}
+ END_PROFILE(SMBsearch);
+ return ERROR_DOS(ERRDOS,ERRnofids);
+ }
+ } else {
+ dirtype = dptr_attr(dptr_num);
+ }
+
+ DEBUG(4,("dptr_num is %d\n",dptr_num));
+
+ if ((dirtype&0x1F) == aVOLID) {
+ memcpy(p,status,21);
+ make_dir_struct(p,"???????????",volume_label(SNUM(conn)),
+ 0,aVOLID,0,!allow_long_path_components);
+ dptr_fill(p+12,dptr_num);
+ if (dptr_zero(p+12) && (status_len==0)) {
+ numentries = 1;
} else {
- dirtype = dptr_attr(dptr_num);
+ numentries = 0;
}
+ p += DIR_STRUCT_SIZE;
+ } else {
+ unsigned int i;
+ maxentries = MIN(maxentries, ((BUFFER_SIZE - (p - outbuf))/DIR_STRUCT_SIZE));
- DEBUG(4,("dptr_num is %d\n",dptr_num));
+ DEBUG(8,("dirpath=<%s> dontdescend=<%s>\n",
+ conn->dirpath,lp_dontdescend(SNUM(conn))));
+ if (in_list(conn->dirpath, lp_dontdescend(SNUM(conn)),True)) {
+ check_descend = True;
+ }
- if (ok) {
- if ((dirtype&0x1F) == aVOLID) {
+ for (i=numentries;(i<maxentries) && !finished;i++) {
+ finished = !get_dir_entry(conn,mask,dirtype,fname,&size,&mode,&date,check_descend);
+ if (!finished) {
memcpy(p,status,21);
- make_dir_struct(p,"???????????",volume_label(SNUM(conn)),
- 0,aVOLID,0,!allow_long_path_components);
- dptr_fill(p+12,dptr_num);
- if (dptr_zero(p+12) && (status_len==0))
- numentries = 1;
- else
- numentries = 0;
- p += DIR_STRUCT_SIZE;
- } else {
- unsigned int i;
- maxentries = MIN(maxentries, ((BUFFER_SIZE - (p - outbuf))/DIR_STRUCT_SIZE));
-
- DEBUG(8,("dirpath=<%s> dontdescend=<%s>\n",
- conn->dirpath,lp_dontdescend(SNUM(conn))));
- if (in_list(conn->dirpath, lp_dontdescend(SNUM(conn)),True))
- check_descend = True;
-
- for (i=numentries;(i<maxentries) && !finished;i++) {
- finished = !get_dir_entry(conn,mask,dirtype,fname,&size,&mode,&date,check_descend);
- if (!finished) {
- memcpy(p,status,21);
- make_dir_struct(p,mask,fname,size, mode,date,
- !allow_long_path_components);
- if (!dptr_fill(p+12,dptr_num)) {
- break;
- }
- numentries++;
- p += DIR_STRUCT_SIZE;
- }
+ make_dir_struct(p,mask,fname,size, mode,date,
+ !allow_long_path_components);
+ if (!dptr_fill(p+12,dptr_num)) {
+ break;
}
+ numentries++;
+ p += DIR_STRUCT_SIZE;
}
- } /* if (ok ) */
+ }
}
-
SearchEmpty:
/* If we were called as SMBffirst with smb_search_id == NULL
and no entries were found then return error and close dirptr
(X/Open spec) */
- if (numentries == 0 || !ok) {
+ if (numentries == 0) {
dptr_close(&dptr_num);
- } else if(ok && expect_close && status_len == 0) {
+ } else if(expect_close && status_len == 0) {
/* Close the dptr - we know it's gone */
dptr_close(&dptr_num);
}