]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
quota: Improve checking of quota file header
authorJan Kara <jack@suse.cz>
Mon, 21 Dec 2009 20:57:04 +0000 (21:57 +0100)
committerJan Kara <jack@suse.cz>
Wed, 23 Dec 2009 12:44:13 +0000 (13:44 +0100)
When we are asked for vfsv0 quota format and the file is in vfsv1
format (or vice versa), refuse to use the quota file. Also return
with error when we don't like the header of quota file.

Signed-off-by: Jan Kara <jack@suse.cz>
fs/quota/quota_v2.c

index 669855cf9b61493345af1c3da962e5078b823700..e3da02f4986f3029c4ab51a30d30fa991a91c6a3 100644 (file)
@@ -97,8 +97,11 @@ static int v2_read_file_info(struct super_block *sb, int type)
        unsigned int version;
 
        if (!v2_read_header(sb, type, &dqhead))
-               return 0;
+               return -1;
        version = le32_to_cpu(dqhead.dqh_version);
+       if ((info->dqi_fmt_id == QFMT_VFS_V0 && version != 0) ||
+           (info->dqi_fmt_id == QFMT_VFS_V1 && version != 1))
+               return -1;
 
        size = sb->s_op->quota_read(sb, type, (char *)&dinfo,
               sizeof(struct v2_disk_dqinfo), V2_DQINFOOFF);