[linux-cifs-client] [PATCH 2/5] cifs: Make CIFSSessSetup and
CIFSTcon use the helpers
Suresh Jayaraman
sjayaraman at suse.de
Fri Apr 17 15:09:39 GMT 2009
Make CIFSSessSetup use the helpers in order to maintain consistency
though it is unused now.
Signed-off-by: Suresh Jayaraman <sjayaraman at suse.de>
---
fs/cifs/connect.c | 63 ++++++++++++++++++++--------------------------------
1 files changed, 24 insertions(+), 39 deletions(-)
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index bacdef1..8473a76 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -2761,38 +2761,29 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
remaining_words =
BCC(smb_buffer_response) / 2;
}
- len =
- UniStrnlen((wchar_t *) bcc_ptr,
- remaining_words - 1);
/* We look for obvious messed up bcc or strings in response so we do not go off
the end since (at least) WIN2K and Windows XP have a major bug in not null
terminating last Unicode string in response */
kfree(ses->serverOS);
- ses->serverOS = kzalloc(2 * (len + 1),
- GFP_KERNEL);
- if (ses->serverOS == NULL)
+ rc = cifs_ucs_to_nls(&(ses->serverOS), bcc_ptr,
+ remaining_words - 1, &len,
+ nls_codepage);
+ if (rc)
goto sesssetup_nomem;
- cifs_strfromUCS_le(ses->serverOS,
- (__le16 *)bcc_ptr,
- len, nls_codepage);
+ cFYI(1, ("serverOS=%s", ses->serverOS));
bcc_ptr += 2 * (len + 1);
remaining_words -= len + 1;
- ses->serverOS[2 * len] = 0;
- ses->serverOS[1 + (2 * len)] = 0;
if (remaining_words > 0) {
- len = UniStrnlen((wchar_t *)bcc_ptr,
- remaining_words-1);
kfree(ses->serverNOS);
- ses->serverNOS = kzalloc(2 * (len + 1),
- GFP_KERNEL);
- if (ses->serverNOS == NULL)
+ rc = cifs_ucs_to_nls(&(ses->serverNOS),
+ bcc_ptr,
+ remaining_words - 1,
+ &len, nls_codepage);
+ if (rc)
goto sesssetup_nomem;
- cifs_strfromUCS_le(ses->serverNOS,
- (__le16 *)bcc_ptr,
- len, nls_codepage);
+ cFYI(1, ("serverNOS=%s",
+ ses->serverNOS));
bcc_ptr += 2 * (len + 1);
- ses->serverNOS[2 * len] = 0;
- ses->serverNOS[1 + (2 * len)] = 0;
if (strncmp(ses->serverNOS,
"NT LAN Manager 4", 16) == 0) {
cFYI(1, ("NT4 server"));
@@ -2800,21 +2791,19 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
}
remaining_words -= len + 1;
if (remaining_words > 0) {
- len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words);
/* last string is not always null terminated
(for e.g. for Windows XP & 2000) */
kfree(ses->serverDomain);
- ses->serverDomain =
- kzalloc(2*(len+1),
- GFP_KERNEL);
- if (ses->serverDomain == NULL)
+ rc = cifs_ucs_to_nls(
+ &(ses->serverDomain),
+ bcc_ptr,
+ remaining_words, &len,
+ nls_codepage);
+ if (rc)
goto sesssetup_nomem;
- cifs_strfromUCS_le(ses->serverDomain,
- (__le16 *)bcc_ptr,
- len, nls_codepage);
+ cFYI(1, ("serverDomain=%s",
+ ses->serverDomain));
bcc_ptr += 2 * (len + 1);
- ses->serverDomain[2*len] = 0;
- ses->serverDomain[1+(2*len)] = 0;
} else { /* else no more room so create
dummy domain string */
kfree(ses->serverDomain);
@@ -3755,16 +3744,12 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses,
pByteArea(smb_buffer_response) <=
BCC(smb_buffer_response)) {
kfree(tcon->nativeFileSystem);
- tcon->nativeFileSystem =
- kzalloc((4 * length) + 2, GFP_KERNEL);
- if (tcon->nativeFileSystem) {
- cifs_strfromUCS_le(
- tcon->nativeFileSystem,
- (__le16 *) bcc_ptr,
- length, nls_codepage);
+ rc = cifs_ucs_to_nls(&(tcon->nativeFileSystem),
+ bcc_ptr, MAX_NAME, &length,
+ nls_codepage);
+ if (!rc)
cFYI(1, ("nativeFileSystem=%s",
tcon->nativeFileSystem));
- }
}
/* else do not bother copying these information fields*/
} else {
More information about the linux-cifs-client
mailing list