From patchwork Fri Apr 17 15:09:39 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suresh Jayaraman X-Patchwork-Id: 18696 Received: from lists.samba.org (mail.samba.org [66.70.73.150]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n3HFAAd2028602 for ; Fri, 17 Apr 2009 15:10:10 GMT Received: from dp.samba.org (localhost [127.0.0.1]) by lists.samba.org (Postfix) with ESMTP id 5C013163C1F for ; Fri, 17 Apr 2009 15:09:49 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on dp.samba.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=3.8 tests=BAYES_00 autolearn=ham version=3.1.7 X-Original-To: linux-cifs-client@lists.samba.org Delivered-To: linux-cifs-client@lists.samba.org Received: from mx1.suse.de (cantor.suse.de [195.135.220.2]) by lists.samba.org (Postfix) with ESMTP id 938D5163B84 for ; Fri, 17 Apr 2009 15:09:29 +0000 (GMT) Received: from Relay2.suse.de (mail2.suse.de [195.135.221.8]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.suse.de (Postfix) with ESMTP id D758E9295B; Fri, 17 Apr 2009 17:09:49 +0200 (CEST) Message-ID: <49E89BB3.5010205@suse.de> Date: Fri, 17 Apr 2009 20:39:39 +0530 From: Suresh Jayaraman User-Agent: Thunderbird 2.0.0.19 (X11/20081227) MIME-Version: 1.0 To: Steve French X-Enigmail-Version: 0.95.7 Cc: "linux-cifs-client@lists.samba.org" , Jeff Layton Subject: [linux-cifs-client] [PATCH 2/5] cifs: Make CIFSSessSetup and CIFSTcon use the helpers X-BeenThere: linux-cifs-client@lists.samba.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: The Linux CIFS VFS client List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-cifs-client-bounces+patchwork-cifs-client=patchwork.kernel.org@lists.samba.org Errors-To: linux-cifs-client-bounces+patchwork-cifs-client=patchwork.kernel.org@lists.samba.org Make CIFSSessSetup use the helpers in order to maintain consistency though it is unused now. Signed-off-by: Suresh Jayaraman --- 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 {