diff mbox

btrfs-progs: check slash in deleting subvolumes.

Message ID 4B32DA34.7030101@jp.fujitsu.com (mailing list archive)
State New, archived
Headers show

Commit Message

TARUISI Hiroaki Dec. 24, 2009, 3:04 a.m. UTC
None
diff mbox

Patch

Index: b/btrfsctl.c
===================================================================
--- a/btrfsctl.c	2009-12-24 11:40:15.000000000 +0900
+++ b/btrfsctl.c	2009-12-24 11:38:51.000000000 +0900
@@ -266,6 +266,7 @@  int main(int ac, char **av)
 	unsigned long command = 0;
 	int len;
 	char *fullpath;
+	char *pos;

 	if (ac == 2 && strcmp(av[1], "-a") == 0) {
 		fprintf(stderr, "Scanning for Btrfs filesystems\n");
@@ -332,6 +333,16 @@  int main(int ac, char **av)
 			command = BTRFS_IOC_SNAP_DESTROY;
 			name = av[i + 1];
 			len = strlen(name);
+			pos = strchr(name, '/');
+			if (pos) {
+				if (*(pos + 1) == '\0')
+					*(pos) = '\0';
+				else {
+					fprintf(stderr,
+						"error: / not allowed in names\n");
+					exit(1);
+				}
+			}
 			if (len == 0 || len >= BTRFS_VOL_NAME_MAX) {
 				fprintf(stderr, "-D size too long\n");
 				exit(1);