diff options
author | Gui Hecheng <guihc.fnst@cn.fujitsu.com> | 2014-03-31 06:03:25 -0400 |
---|---|---|
committer | Chris Mason <clm@fb.com> | 2014-04-07 12:08:45 -0400 |
commit | 9a40f1222a372de77344d85d31f8fe0e1c0e60e7 (patch) | |
tree | 0f4e9fff808aba25e7f9a0b30543b697102b1395 | |
parent | 766b5e5ae78dd04a93a275690a49e23d7dcb1f39 (diff) |
btrfs: filter invalid arg for btrfs resize
Originally following cmds will work:
# btrfs fi resize -10A <mnt>
# btrfs fi resize -10Gaha <mnt>
Filter the arg by checking the return pointer of memparse.
Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: Chris Mason <clm@fb.com>
-rw-r--r-- | fs/btrfs/ioctl.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 59622366c613..05f8df866e4c 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c | |||
@@ -1472,6 +1472,7 @@ static noinline int btrfs_ioctl_resize(struct file *file, | |||
1472 | struct btrfs_trans_handle *trans; | 1472 | struct btrfs_trans_handle *trans; |
1473 | struct btrfs_device *device = NULL; | 1473 | struct btrfs_device *device = NULL; |
1474 | char *sizestr; | 1474 | char *sizestr; |
1475 | char *retptr; | ||
1475 | char *devstr = NULL; | 1476 | char *devstr = NULL; |
1476 | int ret = 0; | 1477 | int ret = 0; |
1477 | int mod = 0; | 1478 | int mod = 0; |
@@ -1539,8 +1540,8 @@ static noinline int btrfs_ioctl_resize(struct file *file, | |||
1539 | mod = 1; | 1540 | mod = 1; |
1540 | sizestr++; | 1541 | sizestr++; |
1541 | } | 1542 | } |
1542 | new_size = memparse(sizestr, NULL); | 1543 | new_size = memparse(sizestr, &retptr); |
1543 | if (new_size == 0) { | 1544 | if (*retptr != '\0' || new_size == 0) { |
1544 | ret = -EINVAL; | 1545 | ret = -EINVAL; |
1545 | goto out_free; | 1546 | goto out_free; |
1546 | } | 1547 | } |