diff options
author | Jeff Layton <jlayton@redhat.com> | 2009-04-30 07:16:21 -0400 |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2009-04-30 11:45:00 -0400 |
commit | cc20c031bb067eb3280a1c4b5c42295093e24863 (patch) | |
tree | 278fbc1a5c3943a1e85552748c40ca63d94e2c84 /fs | |
parent | 066ce6899484d9026acd6ba3a8dbbedb33d7ae1b (diff) |
cifs: convert CIFSTCon to use new unicode helper functions
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Acked-by: Suresh Jayaraman <sjayaraman@suse.de>
Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/cifs/connect.c | 49 |
1 files changed, 14 insertions, 35 deletions
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index bacdef1546b7..e94d6b29af64 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c | |||
@@ -3638,7 +3638,7 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, | |||
3638 | TCONX_RSP *pSMBr; | 3638 | TCONX_RSP *pSMBr; |
3639 | unsigned char *bcc_ptr; | 3639 | unsigned char *bcc_ptr; |
3640 | int rc = 0; | 3640 | int rc = 0; |
3641 | int length; | 3641 | int length, bytes_left; |
3642 | __u16 count; | 3642 | __u16 count; |
3643 | 3643 | ||
3644 | if (ses == NULL) | 3644 | if (ses == NULL) |
@@ -3726,14 +3726,15 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, | |||
3726 | rc = SendReceive(xid, ses, smb_buffer, smb_buffer_response, &length, | 3726 | rc = SendReceive(xid, ses, smb_buffer, smb_buffer_response, &length, |
3727 | CIFS_STD_OP); | 3727 | CIFS_STD_OP); |
3728 | 3728 | ||
3729 | /* if (rc) rc = map_smb_to_linux_error(smb_buffer_response); */ | ||
3730 | /* above now done in SendReceive */ | 3729 | /* above now done in SendReceive */ |
3731 | if ((rc == 0) && (tcon != NULL)) { | 3730 | if ((rc == 0) && (tcon != NULL)) { |
3732 | tcon->tidStatus = CifsGood; | 3731 | tcon->tidStatus = CifsGood; |
3733 | tcon->need_reconnect = false; | 3732 | tcon->need_reconnect = false; |
3734 | tcon->tid = smb_buffer_response->Tid; | 3733 | tcon->tid = smb_buffer_response->Tid; |
3735 | bcc_ptr = pByteArea(smb_buffer_response); | 3734 | bcc_ptr = pByteArea(smb_buffer_response); |
3736 | length = strnlen(bcc_ptr, BCC(smb_buffer_response) - 2); | 3735 | bytes_left = BCC(smb_buffer_response); |
3736 | length = strnlen(bcc_ptr, bytes_left - 2); | ||
3737 | |||
3737 | /* skip service field (NB: this field is always ASCII) */ | 3738 | /* skip service field (NB: this field is always ASCII) */ |
3738 | if (length == 3) { | 3739 | if (length == 3) { |
3739 | if ((bcc_ptr[0] == 'I') && (bcc_ptr[1] == 'P') && | 3740 | if ((bcc_ptr[0] == 'I') && (bcc_ptr[1] == 'P') && |
@@ -3748,39 +3749,17 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, | |||
3748 | } | 3749 | } |
3749 | } | 3750 | } |
3750 | bcc_ptr += length + 1; | 3751 | bcc_ptr += length + 1; |
3752 | bytes_left -= (length + 1); | ||
3751 | strncpy(tcon->treeName, tree, MAX_TREE_SIZE); | 3753 | strncpy(tcon->treeName, tree, MAX_TREE_SIZE); |
3752 | if (smb_buffer->Flags2 & SMBFLG2_UNICODE) { | 3754 | |
3753 | length = UniStrnlen((wchar_t *) bcc_ptr, 512); | 3755 | /* mostly informational -- no need to fail on error here */ |
3754 | if ((bcc_ptr + (2 * length)) - | 3756 | tcon->nativeFileSystem = cifs_strndup(bcc_ptr, bytes_left, |
3755 | pByteArea(smb_buffer_response) <= | 3757 | smb_buffer->Flags2 & |
3756 | BCC(smb_buffer_response)) { | 3758 | SMBFLG2_UNICODE, |
3757 | kfree(tcon->nativeFileSystem); | 3759 | nls_codepage); |
3758 | tcon->nativeFileSystem = | 3760 | |
3759 | kzalloc((4 * length) + 2, GFP_KERNEL); | 3761 | cFYI(1, ("nativeFileSystem=%s", tcon->nativeFileSystem)); |
3760 | if (tcon->nativeFileSystem) { | 3762 | |
3761 | cifs_strfromUCS_le( | ||
3762 | tcon->nativeFileSystem, | ||
3763 | (__le16 *) bcc_ptr, | ||
3764 | length, nls_codepage); | ||
3765 | cFYI(1, ("nativeFileSystem=%s", | ||
3766 | tcon->nativeFileSystem)); | ||
3767 | } | ||
3768 | } | ||
3769 | /* else do not bother copying these information fields*/ | ||
3770 | } else { | ||
3771 | length = strnlen(bcc_ptr, 1024); | ||
3772 | if ((bcc_ptr + length) - | ||
3773 | pByteArea(smb_buffer_response) <= | ||
3774 | BCC(smb_buffer_response)) { | ||
3775 | kfree(tcon->nativeFileSystem); | ||
3776 | tcon->nativeFileSystem = | ||
3777 | kzalloc(length + 1, GFP_KERNEL); | ||
3778 | if (tcon->nativeFileSystem) | ||
3779 | strncpy(tcon->nativeFileSystem, bcc_ptr, | ||
3780 | length); | ||
3781 | } | ||
3782 | /* else do not bother copying these information fields*/ | ||
3783 | } | ||
3784 | if ((smb_buffer_response->WordCount == 3) || | 3763 | if ((smb_buffer_response->WordCount == 3) || |
3785 | (smb_buffer_response->WordCount == 7)) | 3764 | (smb_buffer_response->WordCount == 7)) |
3786 | /* field is in same location */ | 3765 | /* field is in same location */ |