[SCM] Samba Shared Repository - branch master updated - 7bdb571ec4eea6689fa08f40be8b4c0133504f50

Volker Lendecke vlendec at samba.org
Sat Nov 1 18:42:05 GMT 2008


The branch, master has been updated
       via  7bdb571ec4eea6689fa08f40be8b4c0133504f50 (commit)
       via  ac97d7d4b023db8d0e0fef1dc7f2f7b88028eae3 (commit)
       via  cc546c019159608744127eb19db0a39e38ed18c7 (commit)
       via  ab0561f3c39b2d10cc7d82940c9ec4bd7e4e16f8 (commit)
       via  63da08d00fdec52a7384b8c3d6a6c6dee3ace7a7 (commit)
       via  7f9d6f80efbc211977b13ece80fff6adbea929ac (commit)
       via  8637716b4b7b75a289e22141c5761c4850da3f5d (commit)
       via  7a0ed93169e2c274b5386d153e4265b018f39b74 (commit)
      from  4d3eb32a1a1c70a183733771994b4b2868801a66 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 7bdb571ec4eea6689fa08f40be8b4c0133504f50
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Nov 1 17:35:48 2008 +0100

    Remove a bunch of direct inbuf references by adding "buf" to smb_request

commit ac97d7d4b023db8d0e0fef1dc7f2f7b88028eae3
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Nov 1 17:30:37 2008 +0100

    In reply_copy, don't write to inbuf when splitting directory and mask

commit cc546c019159608744127eb19db0a39e38ed18c7
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Nov 1 17:28:25 2008 +0100

    In reply_search(), don't write to inbuf when splitting directory and mask

commit ab0561f3c39b2d10cc7d82940c9ec4bd7e4e16f8
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Nov 1 17:22:15 2008 +0100

    Apply some const to get_lock_*()

commit 63da08d00fdec52a7384b8c3d6a6c6dee3ace7a7
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Nov 1 17:19:31 2008 +0100

    Apply some const to np_write()

commit 7f9d6f80efbc211977b13ece80fff6adbea929ac
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Nov 1 16:24:42 2008 +0100

    Add a "buflen" struct member to smb_request
    
    This removes some explicit inbuf references and also removes a pointless check
    in reply_echo. The buflen can never be more than 64k, this is just a 16 bit
    value.

commit 8637716b4b7b75a289e22141c5761c4850da3f5d
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Nov 1 16:09:02 2008 +0100

    Make use of smb_bufrem()

commit 7a0ed93169e2c274b5386d153e4265b018f39b74
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Nov 1 15:51:19 2008 +0100

    Remove unused extern declaration

-----------------------------------------------------------------------

Summary of changes:
 source3/include/proto.h           |   11 ++-
 source3/include/smb.h             |    2 +
 source3/libsmb/cliconnect.c       |    2 +-
 source3/rpc_server/srv_pipe_hnd.c |    2 +-
 source3/smbd/blocking.c           |   10 ++-
 source3/smbd/ipc.c                |    2 +-
 source3/smbd/message.c            |   14 ++--
 source3/smbd/negprot.c            |    7 +-
 source3/smbd/nttrans.c            |    8 +-
 source3/smbd/pipes.c              |    6 +-
 source3/smbd/process.c            |    8 +-
 source3/smbd/reply.c              |  181 ++++++++++++++++---------------------
 source3/smbd/sesssetup.c          |   22 ++---
 13 files changed, 127 insertions(+), 148 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/include/proto.h b/source3/include/proto.h
index 43cddba..c78c0a0 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -6978,7 +6978,7 @@ void init_rpc_pipe_hnd(void);
 bool fsp_is_np(struct files_struct *fsp);
 NTSTATUS np_open(struct smb_request *smb_req, struct connection_struct *conn,
 		 const char *name, struct files_struct **pfsp);
-NTSTATUS np_write(struct files_struct *fsp, uint8_t *data, size_t len,
+NTSTATUS np_write(struct files_struct *fsp, const uint8_t *data, size_t len,
 		  ssize_t *nwritten);
 NTSTATUS np_read(struct files_struct *fsp, uint8_t *data, size_t len,
 		 ssize_t *nread, bool *is_data_outstanding);
@@ -8351,9 +8351,12 @@ NTSTATUS copy_file(TALLOC_CTX *ctx,
 			int count,
 			bool target_is_directory);
 void reply_copy(struct smb_request *req);
-uint32 get_lock_pid( char *data, int data_offset, bool large_file_format);
-uint64_t get_lock_count( char *data, int data_offset, bool large_file_format);
-uint64_t get_lock_offset( char *data, int data_offset, bool large_file_format, bool *err);
+uint32 get_lock_pid(const uint8_t *data, int data_offset,
+		    bool large_file_format);
+uint64_t get_lock_count(const uint8_t *data, int data_offset,
+			bool large_file_format);
+uint64_t get_lock_offset(const uint8_t *data, int data_offset,
+			 bool large_file_format, bool *err);
 void reply_lockingX(struct smb_request *req);
 void reply_readbmpx(struct smb_request *req);
 void reply_readbs(struct smb_request *req);
diff --git a/source3/include/smb.h b/source3/include/smb.h
index fdbad2a..e2cd0e5 100644
--- a/source3/include/smb.h
+++ b/source3/include/smb.h
@@ -631,6 +631,8 @@ struct smb_request {
 	uint16 vuid;
 	uint16 tid;
 	uint8  wct;
+	uint16_t buflen;
+	const uint8_t *buf;
 	const uint8 *inbuf;
 	uint8 *outbuf;
 	size_t unread_bytes;
diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c
index 6b4798e..1588ae3 100644
--- a/source3/libsmb/cliconnect.c
+++ b/source3/libsmb/cliconnect.c
@@ -516,7 +516,7 @@ static DATA_BLOB cli_session_setup_blob_receive(struct cli_state *cli)
 	p += clistr_pull(cli, cli->server_os, p, sizeof(fstring), -1, STR_TERMINATE);
 
 	/* w2k with kerberos doesn't properly null terminate this field */
-	len = smb_buflen(cli->inbuf) - PTR_DIFF(p, smb_buf(cli->inbuf));
+	len = smb_bufrem(cli->inbuf, p);
 	p += clistr_pull(cli, cli->server_type, p, sizeof(fstring), len, 0);
 
 	return blob2;
diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c
index b892755..92f8928 100644
--- a/source3/rpc_server/srv_pipe_hnd.c
+++ b/source3/rpc_server/srv_pipe_hnd.c
@@ -1046,7 +1046,7 @@ NTSTATUS np_open(struct smb_request *smb_req, struct connection_struct *conn,
 	return NT_STATUS_OK;
 }
 
-NTSTATUS np_write(struct files_struct *fsp, uint8_t *data, size_t len,
+NTSTATUS np_write(struct files_struct *fsp, const uint8_t *data, size_t len,
 		  ssize_t *nwritten)
 {
 	if (!fsp_is_np(fsp)) {
diff --git a/source3/smbd/blocking.c b/source3/smbd/blocking.c
index 4374b50..14ce237 100644
--- a/source3/smbd/blocking.c
+++ b/source3/smbd/blocking.c
@@ -335,10 +335,11 @@ static void reply_lockingX_error(blocking_lock_record *blr, NTSTATUS status)
 	uint32 lock_pid;
 	unsigned char locktype = CVAL(inbuf,smb_vwv3);
 	bool large_file_format = (locktype & LOCKING_ANDX_LARGE_FILES);
-	char *data;
+	uint8_t *data;
 	int i;
 
-	data = smb_buf(inbuf) + ((large_file_format ? 20 : 10)*num_ulocks);
+	data = (uint8_t *)smb_buf(inbuf)
+		+ ((large_file_format ? 20 : 10)*num_ulocks);
 	
 	/* 
 	 * Data now points at the beginning of the list
@@ -423,10 +424,11 @@ static bool process_lockingX(blocking_lock_record *blr)
 	uint64_t count = (uint64_t)0, offset = (uint64_t)0;
 	uint32 lock_pid;
 	bool large_file_format = (locktype & LOCKING_ANDX_LARGE_FILES);
-	char *data;
+	uint8_t *data;
 	NTSTATUS status = NT_STATUS_OK;
 
-	data = smb_buf(inbuf) + ((large_file_format ? 20 : 10)*num_ulocks);
+	data = (uint8_t *)smb_buf(inbuf)
+		+ ((large_file_format ? 20 : 10)*num_ulocks);
 
 	/* 
 	 * Data now points at the beginning of the list
diff --git a/source3/smbd/ipc.c b/source3/smbd/ipc.c
index 0ce2268..d11c8c7 100644
--- a/source3/smbd/ipc.c
+++ b/source3/smbd/ipc.c
@@ -544,7 +544,7 @@ void reply_trans(struct smb_request *req)
 	state->one_way = BITSETW(req->inbuf+smb_vwv5,1);
 
 	srvstr_pull_buf_talloc(state, req->inbuf, req->flags2, &state->name,
-			smb_buf(req->inbuf), STR_TERMINATE);
+			       req->buf, STR_TERMINATE);
 
 	if ((dscnt > state->total_data) || (pscnt > state->total_param) ||
 			!state->name)
diff --git a/source3/smbd/message.c b/source3/smbd/message.c
index 62df5c3..6977b58 100644
--- a/source3/smbd/message.c
+++ b/source3/smbd/message.c
@@ -140,8 +140,8 @@ void reply_sends(struct smb_request *req)
 {
 	struct msg_state *state;
 	int len;
-	char *msg;
-	char *p;
+	const char *msg;
+	const char *p;
 
 	START_PROFILE(SMBsends);
 
@@ -153,7 +153,7 @@ void reply_sends(struct smb_request *req)
 
 	state = talloc(talloc_tos(), struct msg_state);
 
-	p = smb_buf(req->inbuf)+1;
+	p = (const char *)req->buf + 1;
 	p += srvstr_pull_buf_talloc(
 		state, (char *)req->inbuf, req->flags2, &state->from, p,
 		STR_ASCII|STR_TERMINATE) + 1;
@@ -191,7 +191,7 @@ void reply_sends(struct smb_request *req)
 
 void reply_sendstrt(struct smb_request *req)
 {
-	char *p;
+	const char *p;
 
 	START_PROFILE(SMBsendstrt);
 
@@ -211,7 +211,7 @@ void reply_sendstrt(struct smb_request *req)
 		return;
 	}
 
-	p = smb_buf(req->inbuf)+1;
+	p = (const char *)req->buf+1;
 	p += srvstr_pull_buf_talloc(
 		smbd_msg_state, (char *)req->inbuf, req->flags2,
 		&smbd_msg_state->from, p, STR_ASCII|STR_TERMINATE) + 1;
@@ -236,7 +236,7 @@ void reply_sendstrt(struct smb_request *req)
 void reply_sendtxt(struct smb_request *req)
 {
 	int len;
-	char *msg;
+	const char *msg;
 	char *tmp;
 	size_t old_len;
 
@@ -254,7 +254,7 @@ void reply_sendtxt(struct smb_request *req)
 		return;
 	}
 
-	msg = smb_buf(req->inbuf) + 1;
+	msg = (const char *)req->buf + 1;
 
 	old_len = talloc_get_size(smbd_msg_state->msg);
 
diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c
index 84f111f..1fe0193 100644
--- a/source3/smbd/negprot.c
+++ b/source3/smbd/negprot.c
@@ -510,8 +510,7 @@ void reply_negprot(struct smb_request *req)
 	size_t size = smb_len(req->inbuf) + 4;
 	int choice= -1;
 	int protocol;
-	char *p;
-	int bcc = SVAL(smb_buf(req->inbuf),-2);
+	const char *p;
 	int arch = ARCH_ALL;
 	int num_cliprotos;
 	char **cliprotos;
@@ -535,12 +534,12 @@ void reply_negprot(struct smb_request *req)
 		return;
 	}
 
-	p = smb_buf(req->inbuf) + 1;
+	p = (const char *)req->buf + 1;
 
 	num_cliprotos = 0;
 	cliprotos = NULL;
 
-	while (p < (smb_buf(req->inbuf) + bcc)) {
+	while (smb_bufrem(req->inbuf, p) > 0) {
 
 		char **tmp;
 
diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c
index 3084168..dace8f6 100644
--- a/source3/smbd/nttrans.c
+++ b/source3/smbd/nttrans.c
@@ -308,7 +308,7 @@ static void do_ntcreate_pipe_open(connection_struct *conn,
 	TALLOC_CTX *ctx = talloc_tos();
 
 	srvstr_pull_buf_talloc(ctx, (char *)req->inbuf, req->flags2, &fname,
-			smb_buf(req->inbuf), STR_TERMINATE);
+			       req->buf, STR_TERMINATE);
 
 	if (!fname) {
 		reply_botherror(req, NT_STATUS_OBJECT_NAME_NOT_FOUND,
@@ -425,7 +425,7 @@ void reply_ntcreate_and_X(struct smb_request *req)
 #endif
 
 	srvstr_get_path(ctx, (char *)req->inbuf, req->flags2, &fname,
-			smb_buf(req->inbuf), 0, STR_TERMINATE, &status);
+			(const char *)req->buf, 0, STR_TERMINATE, &status);
 
 	if (!NT_STATUS_IS_OK(status)) {
 		reply_nterror(req, status);
@@ -1228,7 +1228,7 @@ void reply_ntrename(struct smb_request *req)
 	connection_struct *conn = req->conn;
 	char *oldname = NULL;
 	char *newname = NULL;
-	char *p;
+	const char *p;
 	NTSTATUS status;
 	bool src_has_wcard = False;
 	bool dest_has_wcard = False;
@@ -1247,7 +1247,7 @@ void reply_ntrename(struct smb_request *req)
 	attrs = SVAL(req->inbuf,smb_vwv0);
 	rename_type = SVAL(req->inbuf,smb_vwv1);
 
-	p = smb_buf(req->inbuf) + 1;
+	p = (const char *)req->buf + 1;
 	p += srvstr_get_path_wcard(ctx, (char *)req->inbuf, req->flags2, &oldname, p,
 				   0, STR_TERMINATE, &status,
 				   &src_has_wcard);
diff --git a/source3/smbd/pipes.c b/source3/smbd/pipes.c
index d971e9d..2ce60c7 100644
--- a/source3/smbd/pipes.c
+++ b/source3/smbd/pipes.c
@@ -49,7 +49,7 @@ void reply_open_pipe_and_X(connection_struct *conn, struct smb_request *req)
 
 	/* XXXX we need to handle passed times, sattr and flags */
 	srvstr_pull_buf_talloc(ctx, req->inbuf, req->flags2, &pipe_name,
-			smb_buf(req->inbuf), STR_TERMINATE);
+			       req->buf, STR_TERMINATE);
 	if (!pipe_name) {
 		reply_botherror(req, NT_STATUS_OBJECT_NAME_NOT_FOUND,
 				ERRDOS, ERRbadpipe);
@@ -122,7 +122,7 @@ void reply_pipe_write(struct smb_request *req)
 	files_struct *fsp = file_fsp(req, SVAL(req->inbuf,smb_vwv0));
 	size_t numtowrite = SVAL(req->inbuf,smb_vwv1);
 	ssize_t nwritten;
-	uint8_t *data;
+	const uint8_t *data;
 
 	if (!fsp_is_np(fsp)) {
 		reply_doserror(req, ERRDOS, ERRbadfid);
@@ -134,7 +134,7 @@ void reply_pipe_write(struct smb_request *req)
 		return;
 	}
 
-	data = (uint8_t *)smb_buf(req->inbuf) + 3;
+	data = req->buf + 3;
 
 	if (numtowrite == 0) {
 		nwritten = 0;
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index a8b93d8..bd665f3 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -20,8 +20,6 @@
 
 #include "includes.h"
 
-extern int smb_echo_count;
-
 /*
  * Size of data we can send to client. Set
  *  by the client for all protocols above CORE.
@@ -377,6 +375,8 @@ void init_smb_request(struct smb_request *req,
 	req->vuid   = SVAL(inbuf, smb_uid);
 	req->tid    = SVAL(inbuf, smb_tid);
 	req->wct    = CVAL(inbuf, smb_wct);
+	req->buflen = smb_buflen(inbuf);
+	req->buf    = (const uint8_t *)smb_buf(inbuf);
 	req->unread_bytes = unread_bytes;
 	req->encrypted = encrypted;
 	req->conn = conn_find(req->tid);
@@ -390,10 +390,10 @@ void init_smb_request(struct smb_request *req,
 		exit_server_cleanly("Invalid SMB request");
 	}
 	/* Ensure bcc is correct. */
-	if (((uint8 *)smb_buf(inbuf)) + smb_buflen(inbuf) > inbuf + req_size) {
+	if (((uint8 *)smb_buf(inbuf)) + req->buflen > inbuf + req_size) {
 		DEBUG(0,("init_smb_request: invalid bcc number %u "
 			"(wct = %u, size %u)\n",
-			(unsigned int)smb_buflen(inbuf),
+			(unsigned int)req->buflen,
 			(unsigned int)req->wct,
 			(unsigned int)req_size));
 		exit_server_cleanly("Invalid SMB request");
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 25480c6..a9c489c 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -517,19 +517,19 @@ void reply_tcon(struct smb_request *req)
 	char *dev = NULL;
 	int pwlen=0;
 	NTSTATUS nt_status;
-	char *p;
+	const char *p;
 	DATA_BLOB password_blob;
 	TALLOC_CTX *ctx = talloc_tos();
 
 	START_PROFILE(SMBtcon);
 
-	if (smb_buflen(req->inbuf) < 4) {
+	if (req->buflen < 4) {
 		reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
 		END_PROFILE(SMBtcon);
 		return;
 	}
 
-	p = smb_buf(req->inbuf)+1;
+	p = (const char *)req->buf + 1;
 	p += srvstr_pull_buf_talloc(ctx, req->inbuf, req->flags2,
 				    &service_buf, p, STR_TERMINATE) + 1;
 	pwlen = srvstr_pull_buf_talloc(ctx, req->inbuf, req->flags2,
@@ -583,7 +583,7 @@ void reply_tcon(struct smb_request *req)
 void reply_tcon_and_X(struct smb_request *req)
 {
 	connection_struct *conn = req->conn;
-	char *service = NULL;
+	const char *service = NULL;
 	DATA_BLOB password;
 	TALLOC_CTX *ctx = talloc_tos();
 	/* what the cleint thinks the device is */
@@ -593,7 +593,7 @@ void reply_tcon_and_X(struct smb_request *req)
 	NTSTATUS nt_status;
 	int passlen;
 	char *path = NULL;
-	char *p, *q;
+	const char *p, *q;
 	uint16 tcon_flags;
 
 	START_PROFILE(SMBtconX);
@@ -614,30 +614,28 @@ void reply_tcon_and_X(struct smb_request *req)
 		conn = NULL;
 	}
 
-	if ((passlen > MAX_PASS_LEN) || (passlen >= smb_buflen(req->inbuf))) {
+	if ((passlen > MAX_PASS_LEN) || (passlen >= req->buflen)) {
 		reply_doserror(req, ERRDOS, ERRbuftoosmall);
 		END_PROFILE(SMBtconX);
 		return;
 	}
 
 	if (global_encrypted_passwords_negotiated) {
-		password = data_blob_talloc(talloc_tos(), smb_buf(req->inbuf),
-					    passlen);
+		password = data_blob_talloc(talloc_tos(), req->buf, passlen);
 		if (lp_security() == SEC_SHARE) {
 			/*
 			 * Security = share always has a pad byte
 			 * after the password.
 			 */
-			p = smb_buf(req->inbuf) + passlen + 1;
+			p = (const char *)req->buf + passlen + 1;
 		} else {
-			p = smb_buf(req->inbuf) + passlen;
+			p = (const char *)req->buf + passlen;
 		}
 	} else {
-		password = data_blob_talloc(talloc_tos(), smb_buf(req->inbuf),
-					    passlen+1);
+		password = data_blob_talloc(talloc_tos(), req->buf, passlen+1);
 		/* Ensure correct termination */
 		password.data[passlen]=0;
-		p = smb_buf(req->inbuf) + passlen + 1;
+		p = (const char *)req->buf + passlen + 1;
 	}
 
 	p += srvstr_pull_buf_talloc(ctx, req->inbuf, req->flags2, &path, p,
@@ -887,8 +885,7 @@ void reply_checkpath(struct smb_request *req)
 	START_PROFILE(SMBcheckpath);
 
 	srvstr_get_path(ctx,(char *)req->inbuf, req->flags2, &name,
-			smb_buf(req->inbuf) + 1, 0,
-			STR_TERMINATE, &status);
+			(const char *)req->buf + 1, 0, STR_TERMINATE, &status);
 	if (!NT_STATUS_IS_OK(status)) {
 		status = map_checkpath_error((char *)req->inbuf, status);
 		reply_nterror(req, status);
@@ -979,13 +976,13 @@ void reply_getatr(struct smb_request *req)
 	int mode=0;
 	SMB_OFF_T size=0;
 	time_t mtime=0;
-	char *p;
+	const char *p;
 	NTSTATUS status;
 	TALLOC_CTX *ctx = talloc_tos();
 
 	START_PROFILE(SMBgetatr);
 
-	p = smb_buf(req->inbuf) + 1;
+	p = (const char *)req->buf + 1;
 	p += srvstr_get_path(ctx, (char *)req->inbuf, req->flags2, &fname, p,
 			     0, STR_TERMINATE, &status);
 	if (!NT_STATUS_IS_OK(status)) {
@@ -1081,7 +1078,7 @@ void reply_setatr(struct smb_request *req)
 	int mode;
 	time_t mtime;
 	SMB_STRUCT_STAT sbuf;
-	char *p;
+	const char *p;
 	NTSTATUS status;
 	TALLOC_CTX *ctx = talloc_tos();
 
@@ -1094,7 +1091,7 @@ void reply_setatr(struct smb_request *req)
 		return;
 	}
 
-	p = smb_buf(req->inbuf) + 1;
+	p = (const char *)req->buf + 1;
 	p += srvstr_get_path(ctx, (char *)req->inbuf, req->flags2, &fname, p,
 				0, STR_TERMINATE, &status);
 	if (!NT_STATUS_IS_OK(status)) {
@@ -1236,7 +1233,7 @@ void reply_dskattr(struct smb_request *req)
 void reply_search(struct smb_request *req)
 {
 	connection_struct *conn = req->conn;
-	char *mask = NULL;
+	const char *mask = NULL;
 	char *directory = NULL;
 	char *fname = NULL;
 	SMB_OFF_T size;
@@ -1246,7 +1243,7 @@ void reply_search(struct smb_request *req)
 	unsigned int numentries = 0;
 	unsigned int maxentries = 0;
 	bool finished = False;
-	char *p;
+	const char *p;
 	int status_len;
 	char *path = NULL;
 	char status[21];
@@ -1281,7 +1278,7 @@ void reply_search(struct smb_request *req)
 	reply_outbuf(req, 1, 3);
 	maxentries = SVAL(req->inbuf,smb_vwv0);
 	dirtype = SVAL(req->inbuf,smb_vwv1);
-	p = smb_buf(req->inbuf) + 1;
+	p = (const char *)req->buf + 1;
 	p += srvstr_get_path_wcard(ctx,
 				(char *)req->inbuf,
 				req->flags2,
@@ -1339,27 +1336,21 @@ void reply_search(struct smb_request *req)
 		}
 
 		p = strrchr_m(directory,'/');
-		if (!p) {
+		if ((p != NULL) && (*directory != '/')) {
+			mask = p + 1;
+			directory = talloc_strndup(ctx, directory,
+						   PTR_DIFF(p, directory));
+		} else {
 			mask = directory;
 			directory = talloc_strdup(ctx,".");
-			if (!directory) {
-				reply_nterror(req, NT_STATUS_NO_MEMORY);
-				END_PROFILE(SMBsearch);
-				return;
-			}
-		} else {
-			*p = 0;
-			mask = p+1;
 		}
 
-		if (*directory == '\0') {
-			directory = talloc_strdup(ctx,".");
-			if (!directory) {
-				reply_nterror(req, NT_STATUS_NO_MEMORY);
-				END_PROFILE(SMBsearch);
-				return;
-			}
+		if (!directory) {
+			reply_nterror(req, NT_STATUS_NO_MEMORY);
+			END_PROFILE(SMBsearch);
+			return;
 		}
+
 		memset((char *)status,'\0',21);
 		SCVAL(status,0,(dirtype & 0x1F));
 
@@ -1550,7 +1541,7 @@ void reply_fclose(struct smb_request *req)


-- 
Samba Shared Repository


More information about the samba-cvs mailing list