summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>1998-01-25 15:44:34 +0000
committerAndrew Tridgell <tridge@samba.org>1998-01-25 15:44:34 +0000
commitccacdb21f5487ff74743b909ec1adb6d8fcb4553 (patch)
treef5164d5252e0d1d9042f7a75124682c16bb15f2b /source
parenta8183658271fa0bd50f41d6608a01c4b01f7f6fb (diff)
downloadsamba-ccacdb21f5487ff74743b909ec1adb6d8fcb4553.tar.gz
samba-ccacdb21f5487ff74743b909ec1adb6d8fcb4553.tar.xz
samba-ccacdb21f5487ff74743b909ec1adb6d8fcb4553.zip
added to 1.9.18 as well
------ always align both the parameter and data bytes on a 4 byte boundary in trans2 responses. I'm not at all convinced this was causing problems, because observations of Win95 show that it produces totally non-aligned paramater bytes and 2 byte aligned data bytes. We were previously always producing 2 byte aligned data and parameter bytes so we already had "better" alignment than Win95. lets hope no clients rely on servers producing unaligned data or parameters!
Diffstat (limited to 'source')
-rw-r--r--source/smbd/trans2.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/source/smbd/trans2.c b/source/smbd/trans2.c
index eb8356cc537..139ded57b24 100644
--- a/source/smbd/trans2.c
+++ b/source/smbd/trans2.c
@@ -55,7 +55,8 @@ static int send_trans2_replies(char *outbuf, int bufsize, char *params,
char *pp = params;
char *pd = pdata;
int params_sent_thistime, data_sent_thistime, total_sent_thistime;
- int alignment_offset = 1;
+ int alignment_offset = 3;
+ int data_alignment_offset = 0;
/* Initially set the wcnt area to be 10 - this is true for all
trans2 replies */
@@ -69,18 +70,28 @@ static int send_trans2_replies(char *outbuf, int bufsize, char *params,
return 0;
}
+ /* when sending params and data ensure that both are nicely aligned */
+ if ((params_to_send % 4) != 0)
+ data_alignment_offset = 4 - (params_to_send % 4);
+
/* Space is bufsize minus Netbios over TCP header minus SMB header */
- /* The alignment_offset is to align the param and data bytes on an even byte
+ /* The alignment_offset is to align the param bytes on an even byte
boundary. NT 4.0 Beta needs this to work correctly. */
- useable_space = bufsize - ((smb_buf(outbuf)+alignment_offset) - outbuf);
+ useable_space = bufsize - ((smb_buf(outbuf)+
+ alignment_offset+data_alignment_offset) -
+ outbuf);
+
/* useable_space can never be more than max_send minus the
alignment offset. */
- useable_space = MIN(useable_space, max_send - alignment_offset);
+ useable_space = MIN(useable_space,
+ max_send - (alignment_offset+data_alignment_offset));
+
- while( params_to_send || data_to_send)
+ while (params_to_send || data_to_send)
{
/* Calculate whether we will totally or partially fill this packet */
- total_sent_thistime = params_to_send + data_to_send + alignment_offset;
+ total_sent_thistime = params_to_send + data_to_send +
+ alignment_offset + data_alignment_offset;
/* We can never send more than useable_space */
total_sent_thistime = MIN(total_sent_thistime, useable_space);
@@ -121,7 +132,8 @@ static int send_trans2_replies(char *outbuf, int bufsize, char *params,
/* The offset of the data bytes is the offset of the
parameter bytes plus the number of parameters being sent this time */
SSVAL(outbuf,smb_droff,((smb_buf(outbuf)+alignment_offset) -
- smb_base(outbuf)) + params_sent_thistime);
+ smb_base(outbuf)) +
+ params_sent_thistime + data_alignment_offset);
SSVAL(outbuf,smb_drdisp, pd - pdata);
}
@@ -130,7 +142,7 @@ static int send_trans2_replies(char *outbuf, int bufsize, char *params,
memcpy((smb_buf(outbuf)+alignment_offset),pp,params_sent_thistime);
/* Copy in the data bytes */
if(data_sent_thistime)
- memcpy(smb_buf(outbuf)+alignment_offset+params_sent_thistime,pd,data_sent_thistime);
+ memcpy(smb_buf(outbuf)+alignment_offset+params_sent_thistime+data_alignment_offset,pd,data_sent_thistime);
DEBUG(9,("t2_rep: params_sent_thistime = %d, data_sent_thistime = %d, useable_space = %d\n",
params_sent_thistime, data_sent_thistime, useable_space));