Commit d185cda7 authored by Steve French's avatar Steve French

[CIFS] rename cifs_strndup to cifs_strndup_from_ucs

In most cases, cifs_strndup is converting from Unicode (UCS2 / UTF-32) to
the configured local code page for the Linux mount (usually UTF8), so
Jeff suggested that to make it more clear that cifs_strndup is doing
a conversion not just memory allocation and copy, rename the function
to including "from_ucs" (ie Unicode)
Signed-off-by: default avatarSteve French <sfrench@us.ibm.com>
parent 5c2503a8
......@@ -2,7 +2,11 @@ Version 1.58
------------
Guard against buffer overruns in various UCS-2 to UTF-8 string conversions
when the UTF-8 string is composed of unusually long (more than 4 byte) converted
characters.
characters. Add support for mounting root of a share which redirects immediately
to DFS target. Convert string conversion functions from Unicode to more
accurately mark string length before allocating memory (which may help the
rare cases where a UTF-8 string is much larger than the UCS2 string that
we converted from).
Version 1.57
------------
......
/*
* fs/cifs/cifs_unicode.c
*
* Copyright (c) International Business Machines Corp., 2000,2005
* Copyright (c) International Business Machines Corp., 2000,2009
* Modified by Steve French (sfrench@us.ibm.com)
*
* This program is free software; you can redistribute it and/or modify
......@@ -244,7 +244,7 @@ cifs_strtoUCS(__le16 *to, const char *from, int len,
}
/*
* cifs_strndup - copy a string from wire format to the local codepage
* cifs_strndup_from_ucs - copy a string from wire format to the local codepage
* @src - source string
* @maxlen - don't walk past this many bytes in the source string
* @is_unicode - is this a unicode string?
......@@ -255,7 +255,7 @@ cifs_strtoUCS(__le16 *to, const char *from, int len,
* error.
*/
char *
cifs_strndup(const char *src, const int maxlen, const bool is_unicode,
cifs_strndup_from_ucs(const char *src, const int maxlen, const bool is_unicode,
const struct nls_table *codepage)
{
int len;
......
......@@ -5,7 +5,7 @@
* Convert a unicode character to upper or lower case using
* compressed tables.
*
* Copyright (c) International Business Machines Corp., 2000,2007
* Copyright (c) International Business Machines Corp., 2000,2009
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -78,8 +78,9 @@ int cifs_ucs2_bytes(const __le16 *from, int maxbytes,
const struct nls_table *codepage);
int cifs_strfromUCS_le(char *, const __le16 *, int, const struct nls_table *);
int cifs_strtoUCS(__le16 *, const char *, int, const struct nls_table *);
char *cifs_strndup(const char *src, const int maxlen, const bool is_unicode,
const struct nls_table *codepage);
char *cifs_strndup_from_ucs(const char *src, const int maxlen,
const bool is_unicode,
const struct nls_table *codepage);
#endif
/*
......
/*
* fs/cifs/cifssmb.c
*
* Copyright (C) International Business Machines Corp., 2002,2008
* Copyright (C) International Business Machines Corp., 2002,2009
* Author(s): Steve French (sfrench@us.ibm.com)
*
* Contains the routines for constructing the SMB PDUs themselves
......@@ -2457,7 +2457,7 @@ querySymLinkRetry:
le16_to_cpu(pSMBr->t2.DataOffset);
/* BB FIXME investigate remapping reserved chars here */
*symlinkinfo = cifs_strndup(data_start, count,
*symlinkinfo = cifs_strndup_from_ucs(data_start, count,
pSMBr->hdr.Flags2 &
SMBFLG2_UNICODE,
nls_codepage);
......@@ -3965,8 +3965,8 @@ parse_DFS_referrals(TRANSACTION2_GET_DFS_REFER_RSP *pSMBr,
/* copy DfsPath */
temp = (char *)ref + le16_to_cpu(ref->DfsPathOffset);
max_len = data_end - temp;
node->path_name = cifs_strndup(temp, max_len, is_unicode,
nls_codepage);
node->path_name = cifs_strndup_from_ucs(temp, max_len,
is_unicode, nls_codepage);
if (IS_ERR(node->path_name)) {
rc = PTR_ERR(node->path_name);
node->path_name = NULL;
......@@ -3976,8 +3976,8 @@ parse_DFS_referrals(TRANSACTION2_GET_DFS_REFER_RSP *pSMBr,
/* copy link target UNC */
temp = (char *)ref + le16_to_cpu(ref->NetworkAddressOffset);
max_len = data_end - temp;
node->node_name = cifs_strndup(temp, max_len, is_unicode,
nls_codepage);
node->node_name = cifs_strndup_from_ucs(temp, max_len,
is_unicode, nls_codepage);
if (IS_ERR(node->node_name)) {
rc = PTR_ERR(node->node_name);
node->node_name = NULL;
......
/*
* fs/cifs/connect.c
*
* Copyright (C) International Business Machines Corp., 2002,2008
* Copyright (C) International Business Machines Corp., 2002,2009
* Author(s): Steve French (sfrench@us.ibm.com)
*
* This library is free software; you can redistribute it and/or modify
......@@ -3463,7 +3463,8 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses,
strncpy(tcon->treeName, tree, MAX_TREE_SIZE);
/* mostly informational -- no need to fail on error here */
tcon->nativeFileSystem = cifs_strndup(bcc_ptr, bytes_left,
tcon->nativeFileSystem = cifs_strndup_from_ucs(bcc_ptr,
bytes_left,
smb_buffer->Flags2 &
SMBFLG2_UNICODE,
nls_codepage);
......
......@@ -3,7 +3,7 @@
*
* SMB/CIFS session setup handling routines
*
* Copyright (c) International Business Machines Corp., 2006, 2007
* Copyright (c) International Business Machines Corp., 2006, 2009
* Author(s): Steve French (sfrench@us.ibm.com)
*
* This library is free software; you can redistribute it and/or modify
......@@ -300,7 +300,7 @@ decode_unicode_ssetup(char **pbcc_area, int bleft, struct cifsSesInfo *ses,
}
kfree(ses->serverOS);
ses->serverOS = cifs_strndup(data, bleft, true, nls_cp);
ses->serverOS = cifs_strndup_from_ucs(data, bleft, true, nls_cp);
cFYI(1, ("serverOS=%s", ses->serverOS));
len = (UniStrnlen((wchar_t *) data, bleft / 2) * 2) + 2;
data += len;
......@@ -309,7 +309,7 @@ decode_unicode_ssetup(char **pbcc_area, int bleft, struct cifsSesInfo *ses,
return;
kfree(ses->serverNOS);
ses->serverNOS = cifs_strndup(data, bleft, true, nls_cp);
ses->serverNOS = cifs_strndup_from_ucs(data, bleft, true, nls_cp);
cFYI(1, ("serverNOS=%s", ses->serverNOS));
len = (UniStrnlen((wchar_t *) data, bleft / 2) * 2) + 2;
data += len;
......@@ -318,7 +318,7 @@ decode_unicode_ssetup(char **pbcc_area, int bleft, struct cifsSesInfo *ses,
return;
kfree(ses->serverDomain);
ses->serverDomain = cifs_strndup(data, bleft, true, nls_cp);
ses->serverDomain = cifs_strndup_from_ucs(data, bleft, true, nls_cp);
cFYI(1, ("serverDomain=%s", ses->serverDomain));
return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment