[dovecot-cvs] dovecot/src/imap commands-util.c,1.47,1.48

cras at dovecot.org cras at dovecot.org
Sat Jun 17 17:02:48 EEST 2006


Update of /var/lib/cvs/dovecot/src/imap
In directory talvi:/tmp/cvs-serv17789

Modified Files:
	commands-util.c 
Log Message:
Fixes to checking if mailbox name is valid. In case mailbox name is invalid,
put it through str_sanitize() before giving it in an error message.



Index: commands-util.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/imap/commands-util.c,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- commands-util.c	13 Jan 2006 20:25:59 -0000	1.47
+++ commands-util.c	17 Jun 2006 14:02:45 -0000	1.48
@@ -4,6 +4,7 @@
 #include "array.h"
 #include "buffer.h"
 #include "str.h"
+#include "str-sanitize.h"
 #include "mail-storage.h"
 #include "commands-util.h"
 #include "imap-parser.h"
@@ -45,14 +46,14 @@
 
 	/* make sure it even looks valid */
 	sep = mail_storage_get_hierarchy_sep(storage);
-	if (*mailbox == '\0' || strspn(mailbox, "\r\n*%?") != 0) {
-		client_send_tagline(cmd, "NO Invalid mailbox name.");
+	if (*mailbox == '\0') {
+		client_send_tagline(cmd, "NO Empty mailbox name.");
 		return FALSE;
 	}
 
 	/* make sure two hierarchy separators aren't next to each others */
 	for (p = mailbox+1; *p != '\0'; p++) {
-		if (p[0] == sep && p[1] == sep) {
+		if (p[0] == sep && p[-1] == sep) {
 			client_send_tagline(cmd, "NO Invalid mailbox name.");
 			return FALSE;
 		}
@@ -84,12 +85,13 @@
 
 		client_send_tagline(cmd, t_strconcat(
 			"NO [TRYCREATE] Mailbox doesn't exist: ",
-			mailbox, NULL));
+			str_sanitize(mailbox, MAILBOX_MAX_NAME_LEN), NULL));
 		break;
 
 	case MAILBOX_NAME_INVALID:
 		client_send_tagline(cmd, t_strconcat(
-			"NO Invalid mailbox name: ", mailbox, NULL));
+			"NO Invalid mailbox name: ",
+			str_sanitize(mailbox, MAILBOX_MAX_NAME_LEN), NULL));
 		break;
 
 	case MAILBOX_NAME_NOINFERIORS:



More information about the dovecot-cvs mailing list