changeset 4314:03e427774958 HEAD

Don't allow "." and ".." mailbox names/masks.
author Timo Sirainen <tss@iki.fi>
date Thu, 08 Jun 2006 19:56:45 +0300
parents d301901c20a5
children 101a7b10bd02
files src/lib-storage/index/maildir/maildir-storage.c src/lib-storage/index/mbox/mbox-storage.c
diffstat 2 files changed, 17 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/maildir/maildir-storage.c	Thu Jun 08 19:54:10 2006 +0300
+++ b/src/lib-storage/index/maildir/maildir-storage.c	Thu Jun 08 19:56:45 2006 +0300
@@ -201,6 +201,12 @@
 	if (*name == '~' || strchr(name, '/') != NULL)
 		return FALSE;
 
+	if (name[0] == '.' && (name[1] == '\0' ||
+			       (name[1] == '.' && name[2] == '\0'))) {
+		/* "." and ".." aren't allowed. */
+		return FALSE;
+	}
+
 	return TRUE;
 }
 
@@ -216,6 +222,12 @@
 	if (*name == '~' || strchr(name, '/') != NULL)
 		return FALSE;
 
+	if (name[0] == '.' && (name[1] == '\0' ||
+			       (name[1] == '.' && name[2] == '\0'))) {
+		/* "." and ".." aren't allowed. */
+		return FALSE;
+	}
+
 	return TRUE;
 }
 
--- a/src/lib-storage/index/mbox/mbox-storage.c	Thu Jun 08 19:54:10 2006 +0300
+++ b/src/lib-storage/index/mbox/mbox-storage.c	Thu Jun 08 19:56:45 2006 +0300
@@ -388,6 +388,11 @@
 		} 
 		newdir = p[0] == '/';
 	}
+	if (mask[0] == '.' && (mask[1] == '\0' ||
+			       (mask[1] == '.' && mask[2] == '\0'))) {
+		/* "." and ".." aren't allowed. */
+		return FALSE;
+	}
 
 	return TRUE;
 }