Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d185cda7 authored by Steve French's avatar Steve French
Browse files

[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
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -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
------------
+3 −3
Original line number Diff line number Diff line
/*
 *   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;
+4 −3
Original line number Diff line number Diff line
@@ -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,7 +78,8 @@ 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,
char *cifs_strndup_from_ucs(const char *src, const int maxlen,
			    const bool is_unicode,
			    const struct nls_table *codepage);
#endif

+6 −6
Original line number Diff line number Diff line
/*
 *   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;
+3 −2
Original line number Diff line number Diff line
/*
 *   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);
Loading