Commit bd69c736 authored by Jeff Layton's avatar Jeff Layton Committed by Greg Kroah-Hartman

CIFS: properly account for new user= field in SPNEGO upcall string allocation

commit 66b8bd3c upstream

[CIFS] properly account for new user= field in SPNEGO upcall string allocation

...it doesn't look like it's being accounted for at the moment. Also
try to reorganize the calculation to make it a little more evident
what each piece means.

This should probably go to the stable series as well...
Signed-off-by: default avatarJeff Layton <jlayton@redhat.com>
Signed-off-by: default avatarSteve French <sfrench@us.ibm.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 978e8c75
...@@ -66,8 +66,8 @@ struct key_type cifs_spnego_key_type = { ...@@ -66,8 +66,8 @@ struct key_type cifs_spnego_key_type = {
.describe = user_describe, .describe = user_describe,
}; };
#define MAX_VER_STR_LEN 9 /* length of longest version string e.g. #define MAX_VER_STR_LEN 8 /* length of longest version string e.g.
strlen(";ver=0xFF") */ strlen("ver=0xFF") */
#define MAX_MECH_STR_LEN 13 /* length of longest security mechanism name, eg #define MAX_MECH_STR_LEN 13 /* length of longest security mechanism name, eg
in future could have strlen(";sec=ntlmsspi") */ in future could have strlen(";sec=ntlmsspi") */
#define MAX_IPV6_ADDR_LEN 42 /* eg FEDC:BA98:7654:3210:FEDC:BA98:7654:3210/60 */ #define MAX_IPV6_ADDR_LEN 42 /* eg FEDC:BA98:7654:3210:FEDC:BA98:7654:3210/60 */
...@@ -81,11 +81,15 @@ cifs_get_spnego_key(struct cifsSesInfo *sesInfo) ...@@ -81,11 +81,15 @@ cifs_get_spnego_key(struct cifsSesInfo *sesInfo)
struct key *spnego_key; struct key *spnego_key;
const char *hostname = server->hostname; const char *hostname = server->hostname;
/* BB: come up with better scheme for determining length */ /* length of fields (with semicolons): ver=0xyz ip4=ipaddress
/* length of fields (with semicolons): ver=0xyz ipv4= ipaddress host= host=hostname sec=mechanism uid=0xFF user=username */
hostname sec=mechanism uid=0x uid */ desc_len = MAX_VER_STR_LEN +
desc_len = MAX_VER_STR_LEN + 5 + MAX_IPV6_ADDR_LEN + 1 + 6 + 6 /* len of "host=" */ + strlen(hostname) +
strlen(hostname) + MAX_MECH_STR_LEN + 8 + (sizeof(uid_t) * 2); 5 /* len of ";ipv4=" */ + MAX_IPV6_ADDR_LEN +
MAX_MECH_STR_LEN +
7 /* len of ";uid=0x" */ + (sizeof(uid_t) * 2) +
6 /* len of ";user=" */ + strlen(sesInfo->userName) + 1;
spnego_key = ERR_PTR(-ENOMEM); spnego_key = ERR_PTR(-ENOMEM);
description = kzalloc(desc_len, GFP_KERNEL); description = kzalloc(desc_len, GFP_KERNEL);
if (description == NULL) if (description == NULL)
......
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