From dc90cd89a7fef3b0a744ef1873193cf2c9d75cad Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 19 Apr 2007 20:50:49 +0000 Subject: r22389: Start preparing for multiple encryption contexts in the server. Allow server to reflect back to calling client the encryption context that was sent. Jeremy. (This used to be commit b49e90335d1e589916b5ab4992e3c4a2d221ca7e) --- source3/lib/util.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/util.c b/source3/lib/util.c index b1db36c250..bb92466a05 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -533,14 +533,20 @@ void smb_set_enclen(char *buf,int len,uint16 enc_ctx_num) Set the length and marker of an smb packet. ********************************************************************/ -void smb_setlen(char *buf,int len) +void smb_setlen(char *buf,int len,const char *frombuf) { _smb_setlen(buf,len); - SCVAL(buf,4,0xFF); - SCVAL(buf,5,'S'); - SCVAL(buf,6,'M'); - SCVAL(buf,7,'B'); + if (frombuf) { + if (buf != frombuf) { + memcpy(buf+4, frombuf+4, 4); + } + } else { + SCVAL(buf,4,0xFF); + SCVAL(buf,5,'S'); + SCVAL(buf,6,'M'); + SCVAL(buf,7,'B'); + } } /******************************************************************* @@ -554,7 +560,7 @@ int set_message(char *buf,int num_words,int num_bytes,BOOL zero) } SCVAL(buf,smb_wct,num_words); SSVAL(buf,smb_vwv + num_words*SIZEOFWORD,num_bytes); - smb_setlen(buf,smb_size + num_words*2 + num_bytes - 4); + smb_setlen(buf,smb_size + num_words*2 + num_bytes - 4, NULL); return (smb_size + num_words*2 + num_bytes); } @@ -566,7 +572,7 @@ int set_message_bcc(char *buf,int num_bytes) { int num_words = CVAL(buf,smb_wct); SSVAL(buf,smb_vwv + num_words*SIZEOFWORD,num_bytes); - smb_setlen(buf,smb_size + num_words*2 + num_bytes - 4); + smb_setlen(buf,smb_size + num_words*2 + num_bytes - 4, NULL); return (smb_size + num_words*2 + num_bytes); } -- cgit