ceph: use snprintf for dirstat content
authorSage Weil <sage@newdream.net>
Thu, 12 May 2011 21:28:05 +0000 (14:28 -0700)
committerSage Weil <sage@newdream.net>
Thu, 19 May 2011 18:25:02 +0000 (11:25 -0700)
We allocate a buffer for rstats if the dirstat option is enabled.  Use
snprintf.

Signed-off-by: Sage Weil <sage@newdream.net>
fs/ceph/dir.c

index 1a867a3601aea88ee25c9fadf399d4a2a3472498..53a5eb417856026593c682150f2b727748948e4b 100644 (file)
@@ -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"