diff mbox

[2/2] btrfs-progs: qgroup limit: add a check for invalid input of 'T/G/M/K'

Message ID 1433323624-2194-2-git-send-email-yangds.fnst@cn.fujitsu.com (mailing list archive)
State Accepted
Headers show

Commit Message

Yang Dongsheng June 3, 2015, 9:27 a.m. UTC
Add a check to error out in the following case:

 # ./btrfs qgroup limit  T /mnt/
Invalid size argument given

Without this patch, btrfs-progs would parse the input as 0
and continue.

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
---
 cmds-qgroup.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

David Sterba June 5, 2015, 4:46 p.m. UTC | #1
On Wed, Jun 03, 2015 at 05:27:04PM +0800, Dongsheng Yang wrote:
> Add a check to error out in the following case:
> 
>  # ./btrfs qgroup limit  T /mnt/
> Invalid size argument given
> 
> Without this patch, btrfs-progs would parse the input as 0
> and continue.
> 
> Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/cmds-qgroup.c b/cmds-qgroup.c
index 5ea4021..9545a20 100644
--- a/cmds-qgroup.c
+++ b/cmds-qgroup.c
@@ -121,6 +121,9 @@  static int parse_limit(const char *p, unsigned long long *s)
 		return 0;
 
 	size = strtoull(p, &endptr, 10);
+	if (p == endptr)
+		return 0;
+
 	switch (*endptr) {
 	case 'T':
 	case 't':