summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/include/proto.h2
-rw-r--r--source3/include/smb.h5
-rw-r--r--source3/include/smb_macros.h2
-rw-r--r--source3/lib/util.c3
-rw-r--r--source3/smbd/aio.c6
-rw-r--r--source3/smbd/blocking.c7
-rw-r--r--source3/smbd/process.c26
-rw-r--r--source3/smbd/reply.c7
8 files changed, 34 insertions, 24 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index c10db31d2a..d58dcef0b4 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -7201,6 +7201,7 @@ void remove_from_common_flags2(uint32 v);
void construct_reply_common_req(struct smb_request *req, char *outbuf);
size_t req_wct_ofs(struct smb_request *req);
void chain_reply(struct smb_request *req);
+bool req_is_in_chain(struct smb_request *req);
void check_reload(time_t t);
void smbd_process(void);
@@ -7275,6 +7276,7 @@ NTSTATUS unlink_internals(connection_struct *conn, struct smb_request *req,
uint32 dirtype, const char *name_in, bool has_wild);
void reply_unlink(struct smb_request *req);
void send_file_readbraw(connection_struct *conn,
+ struct smb_request *req,
files_struct *fsp,
SMB_OFF_T startpos,
size_t nread,
diff --git a/source3/include/smb.h b/source3/include/smb.h
index 9451710255..be6ccbf597 100644
--- a/source3/include/smb.h
+++ b/source3/include/smb.h
@@ -1550,11 +1550,6 @@ enum acl_compatibility {ACL_COMPAT_AUTO, ACL_COMPAT_WINNT, ACL_COMPAT_WIN2K};
#define COPYBUF_SIZE (8*1024)
/*
- * Used in chaining code.
- */
-extern int chain_size;
-
-/*
* Map the Core and Extended Oplock requesst bits down
* to common bits (EXCLUSIVE_OPLOCK & BATCH_OPLOCK).
*/
diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h
index 92c60a7530..fd1bba16a7 100644
--- a/source3/include/smb_macros.h
+++ b/source3/include/smb_macros.h
@@ -135,7 +135,7 @@
/* Note that chain_size must be available as an extern int to this macro. */
-#define smb_offset(p,buf) (PTR_DIFF(p,buf+4) + chain_size)
+#define smb_offset(p,buf) (PTR_DIFF(p,buf+4))
#define smb_len(buf) (PVAL(buf,3)|(PVAL(buf,2)<<8)|((PVAL(buf,1)&1)<<16))
#define _smb_setlen(buf,len) do { buf[0] = 0; buf[1] = ((len)&0x10000)>>16; \
diff --git a/source3/lib/util.c b/source3/lib/util.c
index 195065a1e0..df01c0306f 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -57,9 +57,6 @@ extern unsigned int global_clobber_region_line;
enum protocol_types Protocol = PROTOCOL_COREPLUS;
-/* this is used by the chaining code */
-int chain_size = 0;
-
static enum remote_arch_types ra_type = RA_UNKNOWN;
/***********************************************************************
diff --git a/source3/smbd/aio.c b/source3/smbd/aio.c
index 4ce43c95e8..64d512d675 100644
--- a/source3/smbd/aio.c
+++ b/source3/smbd/aio.c
@@ -141,8 +141,7 @@ bool schedule_aio_read_and_X(connection_struct *conn,
/* Only do this on non-chained and non-chaining reads not using the
* write cache. */
- if (chain_size !=0 || (CVAL(req->vwv+0, 0) != 0xFF)
- || (lp_write_cache_size(SNUM(conn)) != 0) ) {
+ if (req_is_in_chain(req) || (lp_write_cache_size(SNUM(conn)) != 0)) {
return False;
}
@@ -238,8 +237,7 @@ bool schedule_aio_write_and_X(connection_struct *conn,
/* Only do this on non-chained and non-chaining reads not using the
* write cache. */
- if (chain_size !=0 || (CVAL(req->vwv+0, 0) != 0xFF)
- || (lp_write_cache_size(SNUM(conn)) != 0) ) {
+ if (req_is_in_chain(req) || (lp_write_cache_size(SNUM(conn)) != 0)) {
return False;
}
diff --git a/source3/smbd/blocking.c b/source3/smbd/blocking.c
index 9936fb219f..ac1ff00858 100644
--- a/source3/smbd/blocking.c
+++ b/source3/smbd/blocking.c
@@ -47,11 +47,6 @@ typedef struct blocking_lock_record {
Determine if this is a secondary element of a chained SMB.
**************************************************************************/
-static bool in_chained_smb(void)
-{
- return (chain_size != 0);
-}
-
static void received_unlock_msg(struct messaging_context *msg,
void *private_data,
uint32_t msg_type,
@@ -144,7 +139,7 @@ bool push_blocking_lock_request( struct byte_range_lock *br_lck,
blocking_lock_record *blr;
NTSTATUS status;
- if(in_chained_smb() ) {
+ if(req_is_in_chain(req)) {
DEBUG(0,("push_blocking_lock_request: cannot queue a chained request (currently).\n"));
return False;
}
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index d617ef1915..c9fc1fbb6a 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -1359,8 +1359,6 @@ static void construct_reply(char *inbuf, int size, size_t unread_bytes, bool enc
connection_struct *conn;
struct smb_request *req;
- chain_size = 0;
-
if (!(req = talloc(talloc_tos(), struct smb_request))) {
smb_panic("could not allocate smb_request");
}
@@ -2114,3 +2112,27 @@ void smbd_process(void)
exit_server_cleanly(NULL);
}
+
+bool req_is_in_chain(struct smb_request *req)
+{
+ if (req->vwv != (uint16_t *)(req->inbuf+smb_vwv)) {
+ /*
+ * We're right now handling a subsequent request, so we must
+ * be in a chain
+ */
+ return true;
+ }
+
+ if (!is_andx_req(req->cmd)) {
+ return false;
+ }
+
+ if (req->wct < 2) {
+ /*
+ * Okay, an illegal request, but definitely not chained :-)
+ */
+ return false;
+ }
+
+ return (CVAL(req->vwv+0, 0) != 0xFF);
+}
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 25d50470ff..eeb6692eb5 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -2729,6 +2729,7 @@ static void reply_readbraw_error(void)
****************************************************************************/
void send_file_readbraw(connection_struct *conn,
+ struct smb_request *req,
files_struct *fsp,
SMB_OFF_T startpos,
size_t nread,
@@ -2745,7 +2746,7 @@ void send_file_readbraw(connection_struct *conn,
* reply_readbraw has already checked the length.
*/
- if ( (chain_size == 0) && (nread > 0) && (fsp->base_fsp == NULL) &&
+ if ( !req_is_in_chain(req) && (nread > 0) && (fsp->base_fsp == NULL) &&
(fsp->wcp == NULL) && lp_use_sendfile(SNUM(conn)) ) {
ssize_t sendfile_read = -1;
char header[4];
@@ -2963,7 +2964,7 @@ void reply_readbraw(struct smb_request *req)
(unsigned long)mincount,
(unsigned long)nread ) );
- send_file_readbraw(conn, fsp, startpos, nread, mincount);
+ send_file_readbraw(conn, req, fsp, startpos, nread, mincount);
DEBUG(5,("reply_readbraw finished\n"));
END_PROFILE(SMBreadbraw);
@@ -3229,7 +3230,7 @@ static void send_file_readX(connection_struct *conn, struct smb_request *req,
* on a train in Germany :-). JRA.
*/
- if ((chain_size == 0) && (CVAL(req->vwv+0, 0) == 0xFF) &&
+ if (!req_is_in_chain(req) &&
!is_encrypted_packet(req->inbuf) && (fsp->base_fsp == NULL) &&
lp_use_sendfile(SNUM(conn)) && (fsp->wcp == NULL) ) {
uint8 headerbuf[smb_size + 12 * 2];