diff options
Diffstat (limited to 'source3')
-rw-r--r-- | source3/include/proto.h | 2 | ||||
-rw-r--r-- | source3/lib/util.c | 22 | ||||
-rw-r--r-- | source3/libsmb/cliconnect.c | 6 | ||||
-rw-r--r-- | source3/libsmb/clientgen.c | 7 | ||||
-rw-r--r-- | source3/libsmb/clifile.c | 27 | ||||
-rw-r--r-- | source3/libsmb/climessage.c | 2 | ||||
-rw-r--r-- | source3/libsmb/clitrans.c | 12 |
7 files changed, 47 insertions, 31 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h index 6efb6f99e4..d25935c9c6 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -397,6 +397,7 @@ char *attrib_string(uint16 mode); void show_msg(char *buf); void smb_setlen(char *buf,int len); int set_message(char *buf,int num_words,int num_bytes,BOOL zero); +void set_message_bcc(char *buf,int num_bytes); void dos_clean_name(char *s); void unix_clean_name(char *s); void make_dir_struct(char *buf,char *mask,char *fname,SMB_OFF_T size,int mode,time_t date); @@ -801,6 +802,7 @@ int cli_set_port(struct cli_state *cli, int port); BOOL cli_receive_smb(struct cli_state *cli); BOOL cli_send_smb(struct cli_state *cli); void cli_setup_packet(struct cli_state *cli); +void cli_setup_bcc(struct cli_state *cli, void *p); void cli_init_creds(struct cli_state *cli, const struct ntuser_creds *usr); struct cli_state *cli_initialise(struct cli_state *cli); void cli_shutdown(struct cli_state *cli); diff --git a/source3/lib/util.c b/source3/lib/util.c index 2d922aab70..70513c068e 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -335,12 +335,22 @@ void smb_setlen(char *buf,int len) ********************************************************************/ int set_message(char *buf,int num_words,int num_bytes,BOOL zero) { - if (zero) - memset(buf + smb_size,'\0',num_words*2 + num_bytes); - CVAL(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); - return (smb_size + num_words*2 + num_bytes); + if (zero) + memset(buf + smb_size,'\0',num_words*2 + num_bytes); + CVAL(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); + return (smb_size + num_words*2 + num_bytes); +} + +/******************************************************************* + setup only the byte count for a smb message +********************************************************************/ +void 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); } /******************************************************************* diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c index 31bdfdca46..4a957a9ccd 100644 --- a/source3/libsmb/cliconnect.c +++ b/source3/libsmb/cliconnect.c @@ -137,7 +137,7 @@ BOOL cli_session_setup(struct cli_state *cli, memcpy(p,pword,passlen); p += passlen; p += clistr_push(cli, p, user, -1, CLISTR_CONVERT|CLISTR_UPPER|CLISTR_TERMINATE); - set_message(cli->outbuf,10,PTR_DIFF(p,smb_buf(cli->outbuf)),False); + cli_setup_bcc(cli, p); } else { @@ -171,7 +171,7 @@ BOOL cli_session_setup(struct cli_state *cli, p += clistr_push(cli, p, workgroup, -1, CLISTR_CONVERT|CLISTR_TERMINATE|CLISTR_UPPER); p += clistr_push(cli, p, "Unix", -1, CLISTR_CONVERT|CLISTR_TERMINATE); p += clistr_push(cli, p, "Samba", -1, CLISTR_CONVERT|CLISTR_TERMINATE); - set_message(cli->outbuf,13,PTR_DIFF(p,smb_buf(cli->outbuf)),False); + cli_setup_bcc(cli, p); } cli_send_smb(cli); @@ -279,7 +279,7 @@ BOOL cli_send_tconX(struct cli_state *cli, p += clistr_push(cli, p, fullshare, -1, CLISTR_CONVERT | CLISTR_TERMINATE); fstrcpy(p, dev); p += strlen(dev)+1; - set_message(cli->outbuf,4,PTR_DIFF(p,smb_buf(cli->outbuf)),False); + cli_setup_bcc(cli, p); SCVAL(cli->inbuf,smb_rcls, 1); diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c index d7649074db..c25e71ff3d 100644 --- a/source3/libsmb/clientgen.c +++ b/source3/libsmb/clientgen.c @@ -127,6 +127,13 @@ void cli_setup_packet(struct cli_state *cli) } } +/**************************************************************************** +setup the bcc length of the packet from a pointer to the end of the data +****************************************************************************/ +void cli_setup_bcc(struct cli_state *cli, void *p) +{ + set_message_bcc(cli->outbuf, PTR_DIFF(p, smb_buf(cli->outbuf))); +} /**************************************************************************** diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c index 8dc16c3f66..10b6a9e543 100644 --- a/source3/libsmb/clifile.c +++ b/source3/libsmb/clifile.c @@ -33,7 +33,7 @@ BOOL cli_rename(struct cli_state *cli, char *fname_src, char *fname_dst) memset(cli->outbuf,'\0',smb_size); memset(cli->inbuf,'\0',smb_size); - set_message(cli->outbuf,1, 4 + strlen(fname_src) + strlen(fname_dst), True); + set_message(cli->outbuf,1, 0, True); CVAL(cli->outbuf,smb_com) = SMBmv; SSVAL(cli->outbuf,smb_tid,cli->cnum); @@ -43,12 +43,13 @@ BOOL cli_rename(struct cli_state *cli, char *fname_src, char *fname_dst) p = smb_buf(cli->outbuf); *p++ = 4; - pstrcpy(p,fname_src); - unix_to_dos(p,True); - p = skip_string(p,1); + p += clistr_push(cli, p, fname_src, -1, + CLISTR_TERMINATE | CLISTR_CONVERT); *p++ = 4; - pstrcpy(p,fname_dst); - unix_to_dos(p,True); + p += clistr_push(cli, p, fname_dst, -1, + CLISTR_TERMINATE | CLISTR_CONVERT); + + cli_setup_bcc(cli, p); cli_send_smb(cli); if (!cli_receive_smb(cli)) { @@ -72,7 +73,7 @@ BOOL cli_unlink(struct cli_state *cli, char *fname) memset(cli->outbuf,'\0',smb_size); memset(cli->inbuf,'\0',smb_size); - set_message(cli->outbuf,1, 2 + strlen(fname),True); + set_message(cli->outbuf,1, 0,True); CVAL(cli->outbuf,smb_com) = SMBunlink; SSVAL(cli->outbuf,smb_tid,cli->cnum); @@ -82,9 +83,9 @@ BOOL cli_unlink(struct cli_state *cli, char *fname) p = smb_buf(cli->outbuf); *p++ = 4; - pstrcpy(p,fname); - unix_to_dos(p,True); + p += clistr_push(cli, p, fname, -1, CLISTR_TERMINATE | CLISTR_CONVERT); + cli_setup_bcc(cli, p); cli_send_smb(cli); if (!cli_receive_smb(cli)) { return False; @@ -117,7 +118,7 @@ BOOL cli_mkdir(struct cli_state *cli, char *dname) *p++ = 4; p += clistr_push(cli, p, dname, -1, CLISTR_CONVERT|CLISTR_TERMINATE); - set_message(cli->outbuf,0, PTR_DIFF(p, smb_buf(cli->outbuf)), False); + cli_setup_bcc(cli, p); cli_send_smb(cli); if (!cli_receive_smb(cli)) { @@ -151,7 +152,7 @@ BOOL cli_rmdir(struct cli_state *cli, char *dname) *p++ = 4; p += clistr_push(cli, p, dname, -1, CLISTR_TERMINATE|CLISTR_CONVERT); - set_message(cli->outbuf,0, PTR_DIFF(p, smb_buf(cli->outbuf)), False); + cli_setup_bcc(cli, p); cli_send_smb(cli); if (!cli_receive_smb(cli)) { @@ -326,7 +327,7 @@ int cli_open(struct cli_state *cli, char *fname, int flags, int share_mode) p = smb_buf(cli->outbuf); p += clistr_push(cli, p, fname, -1, CLISTR_TERMINATE | CLISTR_CONVERT); - set_message(cli->outbuf,15, PTR_DIFF(p, smb_buf(cli->outbuf)), False); + cli_setup_bcc(cli, p); cli_send_smb(cli); if (!cli_receive_smb(cli)) { @@ -719,7 +720,7 @@ BOOL cli_chkpath(struct cli_state *cli, char *path) *p++ = 4; p += clistr_push(cli, p, path2, -1, CLISTR_TERMINATE | CLISTR_CONVERT); - set_message(cli->outbuf,0,PTR_DIFF(p, smb_buf(cli->outbuf)), False); + cli_setup_bcc(cli, p); cli_send_smb(cli); if (!cli_receive_smb(cli)) { diff --git a/source3/libsmb/climessage.c b/source3/libsmb/climessage.c index c15fdbce8c..058358e2f1 100644 --- a/source3/libsmb/climessage.c +++ b/source3/libsmb/climessage.c @@ -49,7 +49,7 @@ BOOL cli_message_start(struct cli_state *cli, char *host, char *username, unix_to_dos(p,True); p = skip_string(p,1); - set_message(cli->outbuf,0,PTR_DIFF(p,smb_buf(cli->outbuf)),False); + cli_setup_bcc(cli, p); cli_send_smb(cli); diff --git a/source3/libsmb/clitrans.c b/source3/libsmb/clitrans.c index 3afca997cc..630e9f93c0 100644 --- a/source3/libsmb/clitrans.c +++ b/source3/libsmb/clitrans.c @@ -85,8 +85,7 @@ BOOL cli_send_trans(struct cli_state *cli, int trans, memcpy(outparam,param,this_lparam); if (this_ldata) /* data[] */ memcpy(outdata,data,this_ldata); - set_message(cli->outbuf,14+lsetup, /* wcnt, bcc */ - PTR_DIFF(outdata+this_ldata,smb_buf(cli->outbuf)),False); + cli_setup_bcc(cli, outdata+this_ldata); show_msg(cli->outbuf); cli_send_smb(cli); @@ -126,8 +125,7 @@ BOOL cli_send_trans(struct cli_state *cli, int trans, memcpy(outparam,param+tot_param,this_lparam); if (this_ldata) /* data[] */ memcpy(outdata,data+tot_data,this_ldata); - set_message(cli->outbuf,trans==SMBtrans?8:9, /* wcnt, bcc */ - PTR_DIFF(outdata+this_ldata,smb_buf(cli->outbuf)),False); + cli_setup_bcc(cli, outdata+this_ldata); show_msg(cli->outbuf); cli_send_smb(cli); @@ -295,8 +293,7 @@ BOOL cli_send_nt_trans(struct cli_state *cli, if (this_ldata) /* data[] */ memcpy(outdata,data,this_ldata); - set_message(cli->outbuf,19+lsetup, /* wcnt, bcc */ - PTR_DIFF(outdata+this_ldata,smb_buf(cli->outbuf)),False); + cli_setup_bcc(cli, outdata+this_ldata); show_msg(cli->outbuf); cli_send_smb(cli); @@ -335,8 +332,7 @@ BOOL cli_send_nt_trans(struct cli_state *cli, memcpy(outparam,param+tot_param,this_lparam); if (this_ldata) /* data[] */ memcpy(outdata,data+tot_data,this_ldata); - set_message(cli->outbuf,18, - PTR_DIFF(outdata+this_ldata,smb_buf(cli->outbuf)),False); + cli_setup_bcc(cli, outdata+this_ldata); show_msg(cli->outbuf); cli_send_smb(cli); |