no slashes in subvolume names
authorChris Mason <chris.mason@oracle.com>
Tue, 12 Jun 2007 12:21:28 +0000 (08:21 -0400)
committerDavid Woodhouse <dwmw2@hera.kernel.org>
Tue, 12 Jun 2007 12:21:28 +0000 (08:21 -0400)
btrfsctl.c

index b8ba962..196853e 100644 (file)
@@ -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;