diff options
-rw-r--r-- | source3/libsmb/clifile.c | 12 | ||||
-rw-r--r-- | source3/libsmb/clilist.c | 4 | ||||
-rw-r--r-- | source3/libsmb/clistr.c | 7 |
3 files changed, 15 insertions, 8 deletions
diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c index 60e9251995..c5da049cf4 100644 --- a/source3/libsmb/clifile.c +++ b/source3/libsmb/clifile.c @@ -172,6 +172,7 @@ open a file int cli_nt_create(struct cli_state *cli, char *fname, uint32 DesiredAccess) { char *p; + int len; memset(cli->outbuf,'\0',smb_size); memset(cli->inbuf,'\0',smb_size); @@ -194,10 +195,15 @@ int cli_nt_create(struct cli_state *cli, char *fname, uint32 DesiredAccess) SIVAL(cli->outbuf,smb_ntcreate_CreateDisposition, 0x01); SIVAL(cli->outbuf,smb_ntcreate_CreateOptions, 0x0); SIVAL(cli->outbuf,smb_ntcreate_ImpersonationLevel, 0x02); - SSVAL(cli->outbuf,smb_ntcreate_NameLength, strlen(fname)); p = smb_buf(cli->outbuf); - p += clistr_push(cli, p, fname, -1, CLISTR_TERMINATE | CLISTR_CONVERT); + /* this alignment and termination is critical for netapp filers. Don't change */ + p += clistr_align(cli, PTR_DIFF(p, cli->outbuf)); + len = clistr_push(cli, p, fname, -1, CLISTR_CONVERT); + p += len; + SSVAL(cli->outbuf,smb_ntcreate_NameLength, len); + SSVAL(p, 0, 0); + p += 2; cli_setup_bcc(cli, p); @@ -248,7 +254,7 @@ int cli_nt_create_uni(struct cli_state *cli, char *fname, uint32 DesiredAccess) p++; /* Alignment */ pstrcpy(uni, fname); unix_to_dos(uni, True); - p += dos_struni2(p, uni, (strlen(fname) + 1) * 2); + p += dos_struni2(p, uni, (strlen(fname) + 1) * 2) * 2; cli_setup_bcc(cli, p); cli_send_smb(cli); if (!cli_receive_smb(cli)) { diff --git a/source3/libsmb/clilist.c b/source3/libsmb/clilist.c index f7044b27e8..9348b65bad 100644 --- a/source3/libsmb/clilist.c +++ b/source3/libsmb/clilist.c @@ -140,8 +140,8 @@ static int interpret_long_filename(struct cli_state *cli, p += 24; /* short name? */ clistr_pull(cli, finfo->name, p, sizeof(finfo->name), - -1, - CLISTR_TERMINATE | CLISTR_CONVERT); + namelen, + CLISTR_CONVERT); return(ret); } return(SVAL(p,0)); diff --git a/source3/libsmb/clistr.c b/source3/libsmb/clistr.c index 32168cae16..4c7c8e3077 100644 --- a/source3/libsmb/clistr.c +++ b/source3/libsmb/clistr.c @@ -40,17 +40,18 @@ is -1 then no maxiumum is used ****************************************************************************/ int clistr_push(struct cli_state *cli, void *dest, char *src, int dest_len, int flags) { - int len; + int len=0; /* treat a pstring as "unlimited" length */ if (dest_len == -1) { dest_len = sizeof(pstring); } - if (clistr_align(cli, PTR_DIFF(cli->outbuf, dest))) { + if (clistr_align(cli, PTR_DIFF(dest, cli->outbuf))) { *(char *)dest = 0; dest++; dest_len--; + len++; } if (!cli_use_unicode || !(cli->capabilities & CAP_UNICODE)) { @@ -72,7 +73,7 @@ int clistr_push(struct cli_state *cli, void *dest, char *src, int dest_len, int if (flags & CLISTR_UPPER) { strupper_w(dest); } - len = strlen(src)*2; + len += strlen(src)*2; if (flags & CLISTR_TERMINATE) len += 2; return len; } |