aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/connect.c
diff options
context:
space:
mode:
authorChen Gang <gang.chen@asianux.com>2013-07-18 21:01:36 -0400
committerSteve French <smfrench@gmail.com>2013-07-31 00:54:40 -0400
commit057d6332b24a4497c55a761c83c823eed9e3f23b (patch)
tree15ad5c70288bc61084fd01c2f9b0db208d581c12 /fs/cifs/connect.c
parentecb2cf1a6b63825a258ff4fe0d7f3070fbe4676b (diff)
cifs: extend the buffer length enought for sprintf() using
For cifs_set_cifscreds() in "fs/cifs/connect.c", 'desc' buffer length is 'CIFSCREDS_DESC_SIZE' (56 is less than 256), and 'ses->domainName' length may be "255 + '\0'". The related sprintf() may cause memory overflow, so need extend related buffer enough to hold all things. It is also necessary to be sure of 'ses->domainName' must be less than 256, and define the related macro instead of hard code number '256'. Signed-off-by: Chen Gang <gang.chen@asianux.com> Reviewed-by: Jeff Layton <jlayton@redhat.com> Reviewed-by: Shirish Pargaonkar <shirishpargaonkar@gmail.com> Reviewed-by: Scott Lovenberg <scott.lovenberg@gmail.com> CC: <stable@vger.kernel.org> Signed-off-by: Steve French <smfrench@gmail.com>
Diffstat (limited to 'fs/cifs/connect.c')
-rw-r--r--fs/cifs/connect.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index fa68813396b5..d67c550c4980 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -1675,7 +1675,8 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
1675 if (string == NULL) 1675 if (string == NULL)
1676 goto out_nomem; 1676 goto out_nomem;
1677 1677
1678 if (strnlen(string, 256) == 256) { 1678 if (strnlen(string, CIFS_MAX_DOMAINNAME_LEN)
1679 == CIFS_MAX_DOMAINNAME_LEN) {
1679 printk(KERN_WARNING "CIFS: domain name too" 1680 printk(KERN_WARNING "CIFS: domain name too"
1680 " long\n"); 1681 " long\n");
1681 goto cifs_parse_mount_err; 1682 goto cifs_parse_mount_err;
@@ -2276,8 +2277,8 @@ cifs_put_smb_ses(struct cifs_ses *ses)
2276 2277
2277#ifdef CONFIG_KEYS 2278#ifdef CONFIG_KEYS
2278 2279
2279/* strlen("cifs:a:") + INET6_ADDRSTRLEN + 1 */ 2280/* strlen("cifs:a:") + CIFS_MAX_DOMAINNAME_LEN + 1 */
2280#define CIFSCREDS_DESC_SIZE (7 + INET6_ADDRSTRLEN + 1) 2281#define CIFSCREDS_DESC_SIZE (7 + CIFS_MAX_DOMAINNAME_LEN + 1)
2281 2282
2282/* Populate username and pw fields from keyring if possible */ 2283/* Populate username and pw fields from keyring if possible */
2283static int 2284static int