Skip to content

Commit bc0cf58

Browse files
committed
Merge git://git.samba.org/sfrench/cifs-2.6
Pull CIFS fixes from Steve French. * git://git.samba.org/sfrench/cifs-2.6: Fix number parsing in cifs_parse_mount_options Cleanup handling of NULL value passed for a mount option
2 parents 4643b05 + bfa890a commit bc0cf58

File tree

1 file changed

+20
-62
lines changed

1 file changed

+20
-62
lines changed

fs/cifs/connect.c

Lines changed: 20 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ enum {
109109

110110
/* Options which could be blank */
111111
Opt_blank_pass,
112+
Opt_blank_user,
113+
Opt_blank_ip,
112114

113115
Opt_err
114116
};
@@ -183,11 +185,15 @@ static const match_table_t cifs_mount_option_tokens = {
183185
{ Opt_wsize, "wsize=%s" },
184186
{ Opt_actimeo, "actimeo=%s" },
185187

188+
{ Opt_blank_user, "user=" },
189+
{ Opt_blank_user, "username=" },
186190
{ Opt_user, "user=%s" },
187191
{ Opt_user, "username=%s" },
188192
{ Opt_blank_pass, "pass=" },
189193
{ Opt_pass, "pass=%s" },
190194
{ Opt_pass, "password=%s" },
195+
{ Opt_blank_ip, "ip=" },
196+
{ Opt_blank_ip, "addr=" },
191197
{ Opt_ip, "ip=%s" },
192198
{ Opt_ip, "addr=%s" },
193199
{ Opt_unc, "unc=%s" },
@@ -1117,7 +1123,7 @@ static int get_option_ul(substring_t args[], unsigned long *option)
11171123
string = match_strdup(args);
11181124
if (string == NULL)
11191125
return -ENOMEM;
1120-
rc = kstrtoul(string, 10, option);
1126+
rc = kstrtoul(string, 0, option);
11211127
kfree(string);
11221128

11231129
return rc;
@@ -1534,15 +1540,17 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
15341540

15351541
/* String Arguments */
15361542

1543+
case Opt_blank_user:
1544+
/* null user, ie. anonymous authentication */
1545+
vol->nullauth = 1;
1546+
vol->username = NULL;
1547+
break;
15371548
case Opt_user:
15381549
string = match_strdup(args);
15391550
if (string == NULL)
15401551
goto out_nomem;
15411552

1542-
if (!*string) {
1543-
/* null user, ie. anonymous authentication */
1544-
vol->nullauth = 1;
1545-
} else if (strnlen(string, MAX_USERNAME_SIZE) >
1553+
if (strnlen(string, MAX_USERNAME_SIZE) >
15461554
MAX_USERNAME_SIZE) {
15471555
printk(KERN_WARNING "CIFS: username too long\n");
15481556
goto cifs_parse_mount_err;
@@ -1611,14 +1619,15 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
16111619
}
16121620
vol->password[j] = '\0';
16131621
break;
1622+
case Opt_blank_ip:
1623+
vol->UNCip = NULL;
1624+
break;
16141625
case Opt_ip:
16151626
string = match_strdup(args);
16161627
if (string == NULL)
16171628
goto out_nomem;
16181629

1619-
if (!*string) {
1620-
vol->UNCip = NULL;
1621-
} else if (strnlen(string, INET6_ADDRSTRLEN) >
1630+
if (strnlen(string, INET6_ADDRSTRLEN) >
16221631
INET6_ADDRSTRLEN) {
16231632
printk(KERN_WARNING "CIFS: ip address "
16241633
"too long\n");
@@ -1636,12 +1645,6 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
16361645
if (string == NULL)
16371646
goto out_nomem;
16381647

1639-
if (!*string) {
1640-
printk(KERN_WARNING "CIFS: invalid path to "
1641-
"network resource\n");
1642-
goto cifs_parse_mount_err;
1643-
}
1644-
16451648
temp_len = strnlen(string, 300);
16461649
if (temp_len == 300) {
16471650
printk(KERN_WARNING "CIFS: UNC name too long\n");
@@ -1670,11 +1673,7 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
16701673
if (string == NULL)
16711674
goto out_nomem;
16721675

1673-
if (!*string) {
1674-
printk(KERN_WARNING "CIFS: invalid domain"
1675-
" name\n");
1676-
goto cifs_parse_mount_err;
1677-
} else if (strnlen(string, 256) == 256) {
1676+
if (strnlen(string, 256) == 256) {
16781677
printk(KERN_WARNING "CIFS: domain name too"
16791678
" long\n");
16801679
goto cifs_parse_mount_err;
@@ -1693,11 +1692,7 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
16931692
if (string == NULL)
16941693
goto out_nomem;
16951694

1696-
if (!*string) {
1697-
printk(KERN_WARNING "CIFS: srcaddr value not"
1698-
" specified\n");
1699-
goto cifs_parse_mount_err;
1700-
} else if (!cifs_convert_address(
1695+
if (!cifs_convert_address(
17011696
(struct sockaddr *)&vol->srcaddr,
17021697
string, strlen(string))) {
17031698
printk(KERN_WARNING "CIFS: Could not parse"
@@ -1710,11 +1705,6 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
17101705
if (string == NULL)
17111706
goto out_nomem;
17121707

1713-
if (!*string) {
1714-
printk(KERN_WARNING "CIFS: Invalid path"
1715-
" prefix\n");
1716-
goto cifs_parse_mount_err;
1717-
}
17181708
temp_len = strnlen(string, 1024);
17191709
if (string[0] != '/')
17201710
temp_len++; /* missing leading slash */
@@ -1742,11 +1732,7 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
17421732
if (string == NULL)
17431733
goto out_nomem;
17441734

1745-
if (!*string) {
1746-
printk(KERN_WARNING "CIFS: Invalid iocharset"
1747-
" specified\n");
1748-
goto cifs_parse_mount_err;
1749-
} else if (strnlen(string, 1024) >= 65) {
1735+
if (strnlen(string, 1024) >= 65) {
17501736
printk(KERN_WARNING "CIFS: iocharset name "
17511737
"too long.\n");
17521738
goto cifs_parse_mount_err;
@@ -1771,11 +1757,6 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
17711757
if (string == NULL)
17721758
goto out_nomem;
17731759

1774-
if (!*string) {
1775-
printk(KERN_WARNING "CIFS: No socket option"
1776-
" specified\n");
1777-
goto cifs_parse_mount_err;
1778-
}
17791760
if (strnicmp(string, "TCP_NODELAY", 11) == 0)
17801761
vol->sockopt_tcp_nodelay = 1;
17811762
break;
@@ -1784,12 +1765,6 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
17841765
if (string == NULL)
17851766
goto out_nomem;
17861767

1787-
if (!*string) {
1788-
printk(KERN_WARNING "CIFS: Invalid (empty)"
1789-
" netbiosname\n");
1790-
break;
1791-
}
1792-
17931768
memset(vol->source_rfc1001_name, 0x20,
17941769
RFC1001_NAME_LEN);
17951770
/*
@@ -1817,11 +1792,6 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
18171792
if (string == NULL)
18181793
goto out_nomem;
18191794

1820-
if (!*string) {
1821-
printk(KERN_WARNING "CIFS: Empty server"
1822-
" netbiosname specified\n");
1823-
break;
1824-
}
18251795
/* last byte, type, is 0x20 for servr type */
18261796
memset(vol->target_rfc1001_name, 0x20,
18271797
RFC1001_NAME_LEN_WITH_NULL);
@@ -1848,12 +1818,6 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
18481818
if (string == NULL)
18491819
goto out_nomem;
18501820

1851-
if (!*string) {
1852-
cERROR(1, "no protocol version specified"
1853-
" after vers= mount option");
1854-
goto cifs_parse_mount_err;
1855-
}
1856-
18571821
if (strnicmp(string, "cifs", 4) == 0 ||
18581822
strnicmp(string, "1", 1) == 0) {
18591823
/* This is the default */
@@ -1868,12 +1832,6 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
18681832
if (string == NULL)
18691833
goto out_nomem;
18701834

1871-
if (!*string) {
1872-
printk(KERN_WARNING "CIFS: no security flavor"
1873-
" specified\n");
1874-
break;
1875-
}
1876-
18771835
if (cifs_parse_security_flavors(string, vol) != 0)
18781836
goto cifs_parse_mount_err;
18791837
break;

0 commit comments

Comments
 (0)