diff options
Diffstat (limited to 'source3')
-rw-r--r-- | source3/libsmb/clifile.c | 40 | ||||
-rw-r--r-- | source3/libsmb/climessage.c | 10 | ||||
-rw-r--r-- | source3/libsmb/clirap.c | 46 |
3 files changed, 56 insertions, 40 deletions
diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c index 199fd831c0..60e9251995 100644 --- a/source3/libsmb/clifile.c +++ b/source3/libsmb/clifile.c @@ -224,7 +224,7 @@ int cli_nt_create_uni(struct cli_state *cli, char *fname, uint32 DesiredAccess) memset(cli->outbuf,'\0',smb_size); memset(cli->inbuf,'\0',smb_size); - set_message(cli->outbuf,24,(strlen(fname) + 1) * 2 + 1,True); + set_message(cli->outbuf,24,0,True); CVAL(cli->outbuf,smb_com) = SMBntcreateX; SSVAL(cli->outbuf,smb_tid,cli->cnum); @@ -248,8 +248,8 @@ int cli_nt_create_uni(struct cli_state *cli, char *fname, uint32 DesiredAccess) p++; /* Alignment */ pstrcpy(uni, fname); unix_to_dos(uni, True); - dos_struni2(p, uni, (strlen(fname) + 1) * 2); - + p += dos_struni2(p, uni, (strlen(fname) + 1) * 2); + cli_setup_bcc(cli, p); cli_send_smb(cli); if (!cli_receive_smb(cli)) { return -1; @@ -386,7 +386,7 @@ BOOL cli_lock(struct cli_state *cli, int fnum, memset(cli->outbuf,'\0',smb_size); memset(cli->inbuf,'\0', smb_size); - set_message(cli->outbuf,8,10,True); + set_message(cli->outbuf,8,0,True); CVAL(cli->outbuf,smb_com) = SMBlockingX; SSVAL(cli->outbuf,smb_tid,cli->cnum); @@ -403,6 +403,11 @@ BOOL cli_lock(struct cli_state *cli, int fnum, SSVAL(p, 0, cli->pid); SIVAL(p, 2, offset); SIVAL(p, 6, len); + + p += 10; + + cli_setup_bcc(cli, p); + cli_send_smb(cli); cli->timeout = (timeout == -1) ? 0x7FFFFFFF : (timeout + 2*1000); @@ -431,7 +436,7 @@ BOOL cli_unlock(struct cli_state *cli, int fnum, uint32 offset, uint32 len) memset(cli->outbuf,'\0',smb_size); memset(cli->inbuf,'\0',smb_size); - set_message(cli->outbuf,8,10,True); + set_message(cli->outbuf,8,0,True); CVAL(cli->outbuf,smb_com) = SMBlockingX; SSVAL(cli->outbuf,smb_tid,cli->cnum); @@ -448,7 +453,8 @@ BOOL cli_unlock(struct cli_state *cli, int fnum, uint32 offset, uint32 len) SSVAL(p, 0, cli->pid); SIVAL(p, 2, offset); SIVAL(p, 6, len); - + p += 10; + cli_setup_bcc(cli, p); cli_send_smb(cli); if (!cli_receive_smb(cli)) { return False; @@ -478,7 +484,7 @@ BOOL cli_lock64(struct cli_state *cli, int fnum, memset(cli->outbuf,'\0',smb_size); memset(cli->inbuf,'\0', smb_size); - set_message(cli->outbuf,8,20,True); + set_message(cli->outbuf,8,0,True); CVAL(cli->outbuf,smb_com) = SMBlockingX; SSVAL(cli->outbuf,smb_tid,cli->cnum); @@ -497,6 +503,9 @@ BOOL cli_lock64(struct cli_state *cli, int fnum, SIVAL(p, 8, (offset&0xffffffff)); SIVAL(p, 12, (len>>32)); SIVAL(p, 16, (len&0xffffffff)); + p += 20; + + cli_setup_bcc(cli, p); cli_send_smb(cli); cli->timeout = (timeout == -1) ? 0x7FFFFFFF : (timeout + 2*1000); @@ -525,7 +534,7 @@ BOOL cli_unlock64(struct cli_state *cli, int fnum, SMB_BIG_UINT offset, SMB_BIG_ memset(cli->outbuf,'\0',smb_size); memset(cli->inbuf,'\0',smb_size); - set_message(cli->outbuf,8,20,True); + set_message(cli->outbuf,8,0,True); CVAL(cli->outbuf,smb_com) = SMBlockingX; SSVAL(cli->outbuf,smb_tid,cli->cnum); @@ -544,7 +553,8 @@ BOOL cli_unlock64(struct cli_state *cli, int fnum, SMB_BIG_UINT offset, SMB_BIG_ SIVAL(p, 8, (offset&0xffffffff)); SIVAL(p, 12, (len>>32)); SIVAL(p, 16, (len&0xffffffff)); - + p += 20; + cli_setup_bcc(cli, p); cli_send_smb(cli); if (!cli_receive_smb(cli)) { return False; @@ -671,7 +681,7 @@ BOOL cli_setatr(struct cli_state *cli, char *fname, uint16 attr, time_t t) memset(cli->outbuf,'\0',smb_size); memset(cli->inbuf,'\0',smb_size); - set_message(cli->outbuf,8,strlen(fname)+4,True); + set_message(cli->outbuf,8,0,True); CVAL(cli->outbuf,smb_com) = SMBsetatr; SSVAL(cli->outbuf,smb_tid,cli->cnum); @@ -681,11 +691,11 @@ BOOL cli_setatr(struct cli_state *cli, char *fname, uint16 attr, time_t t) put_dos_date3(cli->outbuf,smb_vwv1, t); p = smb_buf(cli->outbuf); - *p = 4; - pstrcpy(p+1, fname); - unix_to_dos(p+1,True); - p = skip_string(p,1); - *p = 4; + *p++ = 4; + p += clistr_push(cli, p, fname, -1, CLISTR_TERMINATE | CLISTR_CONVERT); + *p++ = 4; + + 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 058358e2f1..47139dcfd6 100644 --- a/source3/libsmb/climessage.c +++ b/source3/libsmb/climessage.c @@ -41,13 +41,11 @@ BOOL cli_message_start(struct cli_state *cli, char *host, char *username, p = smb_buf(cli->outbuf); *p++ = 4; - pstrcpy(p,username); - unix_to_dos(p,True); - p = skip_string(p,1); + p += clistr_push(cli, p, username, -1, + CLISTR_TERMINATE|CLISTR_CONVERT); *p++ = 4; - pstrcpy(p,host); - unix_to_dos(p,True); - p = skip_string(p,1); + p += clistr_push(cli, p, host, -1, + CLISTR_TERMINATE|CLISTR_CONVERT); cli_setup_bcc(cli, p); diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index cd0e5ab73f..d1ce4d712e 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -255,10 +255,9 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, p += 4; SIVAL(p,0,stype); p += 4; - - pstrcpy(p, workgroup); - unix_to_dos(p, True); - p = skip_string(p,1); + + p += clistr_push(cli, p, workgroup, -1, + CLISTR_TERMINATE | CLISTR_CONVERT); if (cli_api(cli, param, PTR_DIFF(p,param), 8, /* params, length, max */ @@ -275,29 +274,38 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, count=SVAL(rparam,4); p = rdata; - if (!(stype&0x80000000)) { for (i = 0;i < count;i++, p += 26) { - char *sname = p; - int comment_offset = (IVAL(p,22) & 0xFFFF)-converter; - char *cmnt = comment_offset?(rdata+comment_offset):""; - if (comment_offset < 0 || comment_offset > rdrcnt) continue; - - stype = IVAL(p,18) & ~SV_TYPE_LOCAL_LIST_ONLY; - - dos_to_unix(sname, True); - dos_to_unix(cmnt, True); - fn(sname, stype, cmnt, state); + fstring sname, cmnt; + int comment_offset = (IVAL(p,22) & 0xFFFF)-converter; + char *cptr = comment_offset?(rdata+comment_offset):NULL; + if (comment_offset < 0 || comment_offset > rdrcnt) continue; + + stype = IVAL(p,18) & ~SV_TYPE_LOCAL_LIST_ONLY; + clistr_pull(cli, sname, p, + sizeof(fstring), -1, + CLISTR_TERMINATE | + CLISTR_CONVERT); + fstrcpy(cmnt, ""); + if (cptr) { + clistr_pull(cli, cmnt, cptr, + sizeof(fstring), -1, + CLISTR_TERMINATE | + CLISTR_CONVERT); + } + fn(sname, stype, cmnt, state); } } else { for (i = 0; i < count; i++, p+= 16) { - char *sname = p; - - dos_to_unix(sname, True); + fstring sname; - fn(sname, stype, NULL, state); + clistr_pull(cli, sname, p, + sizeof(fstring), -1, + CLISTR_TERMINATE | + CLISTR_CONVERT); + fn(sname, stype, NULL, state); } } } |