mirror of
https://github.com/adulau/aha.git
synced 2024-12-29 04:06:22 +00:00
cifs: fix session setup unicode string saving to use new unicode helpers
...and change decode_unicode_ssetup to be a void function. It never returns an actual error anyway. Signed-off-by: Jeff Layton <jlayton@redhat.com> Acked-by: Suresh Jayaraman <sjayaraman@suse.de> Signed-off-by: Steve French <sfrench@us.ibm.com>
This commit is contained in:
parent
cc20c031bb
commit
59140797c5
1 changed files with 22 additions and 58 deletions
|
@ -277,12 +277,11 @@ static void ascii_ssetup_strings(char **pbcc_area, struct cifsSesInfo *ses,
|
||||||
*pbcc_area = bcc_ptr;
|
*pbcc_area = bcc_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int decode_unicode_ssetup(char **pbcc_area, int bleft,
|
static void
|
||||||
struct cifsSesInfo *ses,
|
decode_unicode_ssetup(char **pbcc_area, int bleft, struct cifsSesInfo *ses,
|
||||||
const struct nls_table *nls_cp)
|
const struct nls_table *nls_cp)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int len;
|
||||||
int words_left, len;
|
|
||||||
char *data = *pbcc_area;
|
char *data = *pbcc_area;
|
||||||
|
|
||||||
cFYI(1, ("bleft %d", bleft));
|
cFYI(1, ("bleft %d", bleft));
|
||||||
|
@ -300,63 +299,29 @@ static int decode_unicode_ssetup(char **pbcc_area, int bleft,
|
||||||
++bleft;
|
++bleft;
|
||||||
}
|
}
|
||||||
|
|
||||||
words_left = bleft / 2;
|
|
||||||
|
|
||||||
/* save off server operating system */
|
|
||||||
len = UniStrnlen((wchar_t *) data, words_left);
|
|
||||||
|
|
||||||
if (len >= words_left)
|
|
||||||
return rc;
|
|
||||||
|
|
||||||
kfree(ses->serverOS);
|
kfree(ses->serverOS);
|
||||||
/* UTF-8 string will not grow more than four times as big as UCS-16 */
|
ses->serverOS = cifs_strndup(data, bleft, true, nls_cp);
|
||||||
ses->serverOS = kzalloc((4 * len) + 2 /* trailing null */, GFP_KERNEL);
|
cFYI(1, ("serverOS=%s", ses->serverOS));
|
||||||
if (ses->serverOS != NULL) {
|
len = (UniStrnlen((wchar_t *) data, bleft / 2) * 2) + 2;
|
||||||
cifs_strfromUCS_le(ses->serverOS, (__le16 *)data, len, nls_cp);
|
data += len;
|
||||||
cFYI(1, ("serverOS=%s", ses->serverOS));
|
bleft -= len;
|
||||||
}
|
if (bleft <= 0)
|
||||||
data += 2 * (len + 1);
|
return;
|
||||||
words_left -= len + 1;
|
|
||||||
|
|
||||||
/* save off server network operating system */
|
|
||||||
len = UniStrnlen((wchar_t *) data, words_left);
|
|
||||||
|
|
||||||
if (len >= words_left)
|
|
||||||
return rc;
|
|
||||||
|
|
||||||
kfree(ses->serverNOS);
|
kfree(ses->serverNOS);
|
||||||
ses->serverNOS = kzalloc((4 * len) + 2 /* trailing null */, GFP_KERNEL);
|
ses->serverNOS = cifs_strndup(data, bleft, true, nls_cp);
|
||||||
if (ses->serverNOS != NULL) {
|
cFYI(1, ("serverNOS=%s", ses->serverNOS));
|
||||||
cifs_strfromUCS_le(ses->serverNOS, (__le16 *)data, len,
|
len = (UniStrnlen((wchar_t *) data, bleft / 2) * 2) + 2;
|
||||||
nls_cp);
|
data += len;
|
||||||
cFYI(1, ("serverNOS=%s", ses->serverNOS));
|
bleft -= len;
|
||||||
if (strncmp(ses->serverNOS, "NT LAN Manager 4", 16) == 0) {
|
if (bleft <= 0)
|
||||||
cFYI(1, ("NT4 server"));
|
return;
|
||||||
ses->flags |= CIFS_SES_NT4;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
data += 2 * (len + 1);
|
|
||||||
words_left -= len + 1;
|
|
||||||
|
|
||||||
/* save off server domain */
|
|
||||||
len = UniStrnlen((wchar_t *) data, words_left);
|
|
||||||
|
|
||||||
if (len > words_left)
|
|
||||||
return rc;
|
|
||||||
|
|
||||||
kfree(ses->serverDomain);
|
kfree(ses->serverDomain);
|
||||||
ses->serverDomain = kzalloc((4 * len) + 2, GFP_KERNEL);
|
ses->serverDomain = cifs_strndup(data, bleft, true, nls_cp);
|
||||||
if (ses->serverDomain != NULL) {
|
cFYI(1, ("serverDomain=%s", ses->serverDomain));
|
||||||
cifs_strfromUCS_le(ses->serverDomain, (__le16 *)data, len,
|
|
||||||
nls_cp);
|
|
||||||
cFYI(1, ("serverDomain=%s", ses->serverDomain));
|
|
||||||
}
|
|
||||||
data += 2 * (len + 1);
|
|
||||||
words_left -= len + 1;
|
|
||||||
|
|
||||||
cFYI(1, ("words left: %d", words_left));
|
return;
|
||||||
|
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int decode_ascii_ssetup(char **pbcc_area, int bleft,
|
static int decode_ascii_ssetup(char **pbcc_area, int bleft,
|
||||||
|
@ -709,8 +674,7 @@ CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses, int first_time,
|
||||||
++bcc_ptr;
|
++bcc_ptr;
|
||||||
--bytes_remaining;
|
--bytes_remaining;
|
||||||
}
|
}
|
||||||
rc = decode_unicode_ssetup(&bcc_ptr, bytes_remaining,
|
decode_unicode_ssetup(&bcc_ptr, bytes_remaining, ses, nls_cp);
|
||||||
ses, nls_cp);
|
|
||||||
} else {
|
} else {
|
||||||
rc = decode_ascii_ssetup(&bcc_ptr, bytes_remaining,
|
rc = decode_ascii_ssetup(&bcc_ptr, bytes_remaining,
|
||||||
ses, nls_cp);
|
ses, nls_cp);
|
||||||
|
|
Loading…
Reference in a new issue