From: Sage Weil <sage@newdream.net>
Date: Thu, 12 May 2011 21:28:05 +0000 (-0700)
Subject: ceph: use snprintf for dirstat content
X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=ae598083015e22d1802617c18d3408971b1bddc0;p=GitHub%2Fexynos8895%2Fandroid_kernel_samsung_universal8895.git

ceph: use snprintf for dirstat content

We allocate a buffer for rstats if the dirstat option is enabled.  Use
snprintf.

Signed-off-by: Sage Weil <sage@newdream.net>
---

diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
index 1a867a3601ae..53a5eb417856 100644
--- a/fs/ceph/dir.c
+++ b/fs/ceph/dir.c
@@ -1066,16 +1066,17 @@ static ssize_t ceph_read_dir(struct file *file, char __user *buf, size_t size,
 	struct inode *inode = file->f_dentry->d_inode;
 	struct ceph_inode_info *ci = ceph_inode(inode);
 	int left;
+	const int bufsize = 1024;
 
 	if (!ceph_test_mount_opt(ceph_sb_to_client(inode->i_sb), DIRSTAT))
 		return -EISDIR;
 
 	if (!cf->dir_info) {
-		cf->dir_info = kmalloc(1024, GFP_NOFS);
+		cf->dir_info = kmalloc(bufsize, GFP_NOFS);
 		if (!cf->dir_info)
 			return -ENOMEM;
 		cf->dir_info_len =
-			sprintf(cf->dir_info,
+			snprintf(cf->dir_info, bufsize,
 				"entries:   %20lld\n"
 				" files:    %20lld\n"
 				" subdirs:  %20lld\n"