Commit 9a40f1222a372de77344d85d31f8fe0e1c0e60e7

Authored by Gui Hecheng
Committed by Chris Mason
1 parent 766b5e5ae7

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>

Showing 1 changed file with 3 additions and 2 deletions Side-by-side Diff

... ... @@ -1472,6 +1472,7 @@
1472 1472 struct btrfs_trans_handle *trans;
1473 1473 struct btrfs_device *device = NULL;
1474 1474 char *sizestr;
  1475 + char *retptr;
1475 1476 char *devstr = NULL;
1476 1477 int ret = 0;
1477 1478 int mod = 0;
... ... @@ -1539,8 +1540,8 @@
1539 1540 mod = 1;
1540 1541 sizestr++;
1541 1542 }
1542   - new_size = memparse(sizestr, NULL);
1543   - if (new_size == 0) {
  1543 + new_size = memparse(sizestr, &retptr);
  1544 + if (*retptr != '\0' || new_size == 0) {
1544 1545 ret = -EINVAL;
1545 1546 goto out_free;
1546 1547 }