From 9ea6a6fd926e56eddf74f985f5b1682d9239041a Mon Sep 17 00:00:00 2001 From: Chris Mason Date: Tue, 12 Jun 2007 08:21:28 -0400 Subject: no slashes in subvolume names --- btrfsctl.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/btrfsctl.c b/btrfsctl.c index b8ba9626..196853e3 100644 --- a/btrfsctl.c +++ b/btrfsctl.c @@ -38,6 +38,7 @@ int main(int ac, char **av) struct stat st; DIR *dirstream; unsigned long command = 0; + int len; for (i = 1; i < ac - 1; i++) { if (strcmp(av[i], "-s") == 0) { @@ -46,8 +47,15 @@ int main(int ac, char **av) print_usage(); } name = av[i + 1]; - if (strlen(name) >= BTRFS_VOL_NAME_MAX) { - fprintf(stderr, "snapshot name is too long\n"); + len = strlen(name); + if (len == 0 || len >= BTRFS_VOL_NAME_MAX) { + fprintf(stderr, + "snapshot name zero length or too long\n"); + exit(1); + } + if (strchr(name, '/')) { + fprintf(stderr, + "error: / not allowed in names\n"); exit(1); } command = BTRFS_IOC_SNAP_CREATE; -- cgit v1.2.3