------------
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
}
/*
- * 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?
* 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;
* 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
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
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);
/* 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;
/* 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
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);
*
* 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
}
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;
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;
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;