summaryrefslogtreecommitdiff
path: root/source3/libsmb
diff options
context:
space:
mode:
Diffstat (limited to 'source3/libsmb')
-rw-r--r--source3/libsmb/clientgen.c44
-rw-r--r--source3/libsmb/pwd_cache.c20
2 files changed, 51 insertions, 13 deletions
diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c
index 8aa857df8a..5ae84f763b 100644
--- a/source3/libsmb/clientgen.c
+++ b/source3/libsmb/clientgen.c
@@ -1255,7 +1255,7 @@ size_t cli_read(struct cli_state *cli, int fnum, char *buf, off_t offset, size_t
/****************************************************************************
issue a single SMBwrite and don't wait for a reply
****************************************************************************/
-static void cli_issue_write(struct cli_state *cli, int fnum, off_t offset, char *buf,
+static void cli_issue_write(struct cli_state *cli, int fnum, off_t offset, uint16 mode, char *buf,
size_t size, int i)
{
char *p;
@@ -1272,6 +1272,8 @@ static void cli_issue_write(struct cli_state *cli, int fnum, off_t offset, char
CVAL(cli->outbuf,smb_vwv0) = 0xFF;
SSVAL(cli->outbuf,smb_vwv2,fnum);
SIVAL(cli->outbuf,smb_vwv3,offset);
+ SIVAL(cli->outbuf,smb_vwv5,IS_BITS_SET_ALL(mode, 0x0008) ? 0xFFFFFFFF : 0);
+ SSVAL(cli->outbuf,smb_vwv7,mode);
SSVAL(cli->outbuf,smb_vwv10,size);
SSVAL(cli->outbuf,smb_vwv11,
@@ -1282,13 +1284,20 @@ static void cli_issue_write(struct cli_state *cli, int fnum, off_t offset, char
SSVAL(cli->outbuf,smb_mid,cli->mid + i);
+ show_msg(cli->outbuf);
send_smb(cli->fd,cli->outbuf);
}
/****************************************************************************
write to a file
+ write_mode: 0x0001 disallow write cacheing
+ 0x0002 return bytes remaining
+ 0x0004 use raw named pipe protocol
+ 0x0008 start of message mode named pipe protocol
****************************************************************************/
-size_t cli_write(struct cli_state *cli, int fnum, char *buf, off_t offset, size_t size)
+size_t cli_write(struct cli_state *cli,
+ int fnum, uint16 write_mode,
+ char *buf, off_t offset, size_t size)
{
int total = -1;
int issued=0;
@@ -1305,7 +1314,9 @@ size_t cli_write(struct cli_state *cli, int fnum, char *buf, off_t offset, size_
while (issued - received < mpx && issued < blocks) {
int size1 = MIN(block, size-issued*block);
- cli_issue_write(cli, fnum, offset+issued*block, buf + issued*block,
+ cli_issue_write(cli, fnum, offset+issued*block,
+ write_mode,
+ buf + issued*block,
size1, issued);
issued++;
}
@@ -2226,9 +2237,12 @@ initialise a client structure
BOOL cli_initialise(struct cli_state *cli)
{
if (cli->initialised)
- cli_shutdown(cli);
+ {
+ cli_shutdown(cli);
+ }
memset(cli, 0, sizeof(*cli));
+
cli->fd = -1;
cli->cnum = -1;
cli->pid = (uint16)getpid();
@@ -2241,8 +2255,12 @@ BOOL cli_initialise(struct cli_state *cli)
cli->outbuf = (char *)malloc(cli->bufsize);
cli->inbuf = (char *)malloc(cli->bufsize);
if (!cli->outbuf || !cli->inbuf)
- return False;
+ {
+ return False;
+ }
+
cli->initialised = 1;
+
return True;
}
@@ -2252,9 +2270,13 @@ shutdown a client structure
void cli_shutdown(struct cli_state *cli)
{
if (cli->outbuf)
- free(cli->outbuf);
+ {
+ free(cli->outbuf);
+ }
if (cli->inbuf)
- free(cli->inbuf);
+ {
+ free(cli->inbuf);
+ }
#ifdef WITH_SSL
if (cli->fd != -1)
sslutil_disconnect(cli->fd);
@@ -2454,7 +2476,9 @@ BOOL cli_establish_connection(struct cli_state *cli,
{
DEBUG(1,("failed session setup\n"));
if (do_shutdown)
- cli_shutdown(cli);
+ {
+ cli_shutdown(cli);
+ }
return False;
}
if (do_tcon)
@@ -2464,7 +2488,9 @@ BOOL cli_establish_connection(struct cli_state *cli,
{
DEBUG(1,("failed tcon_X\n"));
if (do_shutdown)
- cli_shutdown(cli);
+ {
+ cli_shutdown(cli);
+ }
return False;
}
}
diff --git a/source3/libsmb/pwd_cache.c b/source3/libsmb/pwd_cache.c
index 92eee015b3..c4c578cde6 100644
--- a/source3/libsmb/pwd_cache.c
+++ b/source3/libsmb/pwd_cache.c
@@ -168,8 +168,14 @@ void pwd_set_lm_nt_16(struct pwd_info *pwd, uchar lm_pwd[16], uchar nt_pwd[16])
void pwd_get_lm_nt_16(struct pwd_info *pwd, uchar lm_pwd[16], uchar nt_pwd[16])
{
pwd_deobfuscate(pwd);
- memcpy(lm_pwd, pwd->smb_lm_pwd, 16);
- memcpy(nt_pwd, pwd->smb_nt_pwd, 16);
+ if (lm_pwd != NULL)
+ {
+ memcpy(lm_pwd, pwd->smb_lm_pwd, 16);
+ }
+ if (nt_pwd != NULL)
+ {
+ memcpy(nt_pwd, pwd->smb_nt_pwd, 16);
+ }
pwd_obfuscate(pwd);
}
@@ -229,7 +235,13 @@ void pwd_make_lm_nt_owf(struct pwd_info *pwd, uchar cryptkey[8])
void pwd_get_lm_nt_owf(struct pwd_info *pwd, uchar lm_owf[24], uchar nt_owf[24])
{
pwd_deobfuscate(pwd);
- memcpy(lm_owf, pwd->smb_lm_owf, 24);
- memcpy(nt_owf, pwd->smb_nt_owf, 24);
+ if (lm_owf != NULL)
+ {
+ memcpy(lm_owf, pwd->smb_lm_owf, 24);
+ }
+ if (nt_owf != NULL)
+ {
+ memcpy(nt_owf, pwd->smb_nt_owf, 24);
+ }
pwd_obfuscate(pwd);
}