cifs: cifsroot: add more err checking
make cifs more verbose about buffer size errors and add some comments Signed-off-by: Aurelien Aptel <aaptel@suse.com> Signed-off-by: Steve French <stfrench@microsoft.com>
This commit is contained in:
parent
c3498185b7
commit
352f2c9a57
@ -24,6 +24,7 @@ static char root_opts[1024] __initdata = DEFAULT_MNT_OPTS;
|
|||||||
|
|
||||||
static __be32 __init parse_srvaddr(char *start, char *end)
|
static __be32 __init parse_srvaddr(char *start, char *end)
|
||||||
{
|
{
|
||||||
|
/* TODO: ipv6 support */
|
||||||
char addr[sizeof("aaa.bbb.ccc.ddd")];
|
char addr[sizeof("aaa.bbb.ccc.ddd")];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
@ -50,14 +51,24 @@ static int __init cifs_root_setup(char *line)
|
|||||||
if (!s || s[1] == '\0')
|
if (!s || s[1] == '\0')
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
/* make s point to ',' or '\0' at end of line */
|
||||||
s = strchrnul(s, ',');
|
s = strchrnul(s, ',');
|
||||||
|
/* len is strlen(unc) + '\0' */
|
||||||
len = s - line + 1;
|
len = s - line + 1;
|
||||||
if (len <= sizeof(root_dev)) {
|
if (len > sizeof(root_dev)) {
|
||||||
|
printk(KERN_ERR "Root-CIFS: UNC path too long\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
strlcpy(root_dev, line, len);
|
strlcpy(root_dev, line, len);
|
||||||
srvaddr = parse_srvaddr(&line[2], s);
|
srvaddr = parse_srvaddr(&line[2], s);
|
||||||
if (*s) {
|
if (*s) {
|
||||||
snprintf(root_opts, sizeof(root_opts), "%s,%s",
|
int n = snprintf(root_opts,
|
||||||
|
sizeof(root_opts), "%s,%s",
|
||||||
DEFAULT_MNT_OPTS, s + 1);
|
DEFAULT_MNT_OPTS, s + 1);
|
||||||
|
if (n >= sizeof(root_opts)) {
|
||||||
|
printk(KERN_ERR "Root-CIFS: mount options string too long\n");
|
||||||
|
root_opts[sizeof(root_opts)-1] = '\0';
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user