summaryrefslogtreecommitdiff
path: root/source3/smbd/reply.c
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2009-08-07 09:31:45 +0200
committerStefan Metzmacher <metze@samba.org>2009-08-07 14:18:17 +0200
commitc50a03e4e2c47b828f81f2e4dc214ec84d9cae63 (patch)
tree9b3a93b399215737652d57d3fdff350fe363ed9c /source3/smbd/reply.c
parentdfae090c5d0c238f2c620d77edc6bb6cf1bb027b (diff)
downloadsamba-c50a03e4e2c47b828f81f2e4dc214ec84d9cae63.tar.gz
samba-c50a03e4e2c47b828f81f2e4dc214ec84d9cae63.tar.bz2
samba-c50a03e4e2c47b828f81f2e4dc214ec84d9cae63.zip
s3:smbd: remove dirptr and dirpath from connection_struct
They're both only used in the context of a function, so we can make them stack variables. metze
Diffstat (limited to 'source3/smbd/reply.c')
-rw-r--r--source3/smbd/reply.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 750915b1cb..f6028a3eef 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -1366,6 +1366,7 @@ void reply_search(struct smb_request *req)
bool allow_long_path_components = (req->flags2 & FLAGS2_LONG_PATH_COMPONENTS) ? True : False;
TALLOC_CTX *ctx = talloc_tos();
bool ask_sharemode = lp_parm_bool(SNUM(conn), "smbd", "search ask sharemode", true);
+ struct dptr_struct *dirptr = NULL;
START_PROFILE(SMBsearch);
@@ -1446,14 +1447,15 @@ void reply_search(struct smb_request *req)
mask,
mask_contains_wcard,
dirtype,
- &conn->dirptr);
+ &dirptr);
if (!NT_STATUS_IS_OK(nt_status)) {
reply_nterror(req, nt_status);
goto out;
}
- dptr_num = dptr_dnum(conn->dirptr);
+ dptr_num = dptr_dnum(dirptr);
} else {
int status_dirtype;
+ const char *dirpath;
memcpy(status,p,21);
status_dirtype = CVAL(status,0) & 0x1F;
@@ -1461,11 +1463,17 @@ void reply_search(struct smb_request *req)
dirtype = status_dirtype;
}
- conn->dirptr = dptr_fetch(status+12,&dptr_num);
- if (!conn->dirptr) {
+ dirptr = dptr_fetch(status+12,&dptr_num);
+ if (!dirptr) {
goto SearchEmpty;
}
- string_set(&conn->dirpath,dptr_path(dptr_num));
+ dirpath = dptr_path(dptr_num);
+ directory = talloc_strdup(ctx, dirpath);
+ if (!directory) {
+ reply_nterror(req, NT_STATUS_NO_MEMORY);
+ goto out;
+ }
+
mask = dptr_wcard(dptr_num);
if (!mask) {
goto SearchEmpty;
@@ -1481,7 +1489,7 @@ void reply_search(struct smb_request *req)
DEBUG(4,("dptr_num is %d\n",dptr_num));
/* Initialize per SMBsearch/SMBffirst/SMBfunique operation data */
- dptr_init_search_op(conn->dirptr);
+ dptr_init_search_op(dirptr);
if ((dirtype&0x1F) == aVOLID) {
char buf[DIR_STRUCT_SIZE];
@@ -1512,14 +1520,14 @@ void reply_search(struct smb_request *req)
/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)) {
+ directory,lp_dontdescend(SNUM(conn))));
+ if (in_list(directory, lp_dontdescend(SNUM(conn)),True)) {
check_descend = True;
}
for (i=numentries;(i<maxentries) && !finished;i++) {
finished = !get_dir_entry(ctx,
- conn,
+ dirptr,
mask,
dirtype,
&fname,
@@ -1597,18 +1605,15 @@ void reply_search(struct smb_request *req)
SSVAL(req->outbuf, smb_flg2,
(SVAL(req->outbuf, smb_flg2) & (~FLAGS2_UNICODE_STRINGS)));
- if (!directory) {
- directory = dptr_path(dptr_num);
- }
-
DEBUG(4,("%s mask=%s path=%s dtype=%d nument=%u of %u\n",
smb_fn_name(req->cmd),
mask,
- directory ? directory : "./",
+ directory,
dirtype,
numentries,
maxentries ));
out:
+ TALLOC_FREE(directory);
TALLOC_FREE(smb_fname);
END_PROFILE(SMBsearch);
return;