summaryrefslogtreecommitdiff
path: root/qgroup.c
diff options
context:
space:
mode:
Diffstat (limited to 'qgroup.c')
-rw-r--r--qgroup.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/qgroup.c b/qgroup.c
index 4083b57e..dafde12b 100644
--- a/qgroup.c
+++ b/qgroup.c
@@ -22,15 +22,29 @@
u64 parse_qgroupid(char *p)
{
char *s = strchr(p, '/');
+ char *ptr_src_end = p + strlen(p);
+ char *ptr_parse_end = NULL;
u64 level;
u64 id;
- if (!s)
- return atoll(p);
- level = atoll(p);
- id = atoll(s + 1);
+ if (!s) {
+ id = strtoull(p, &ptr_parse_end, 10);
+ if (ptr_parse_end != ptr_src_end)
+ goto err;
+ return id;
+ }
+ level = strtoull(p, &ptr_parse_end, 10);
+ if (ptr_parse_end != s)
+ goto err;
+
+ id = strtoull(s+1, &ptr_parse_end, 10);
+ if (ptr_parse_end != ptr_src_end)
+ goto err;
return (level << 48) | id;
+err:
+ fprintf(stderr, "ERROR:invalid qgroupid\n");
+ exit(-1);
}
int qgroup_inherit_size(struct btrfs_qgroup_inherit *p)