dovecot-1.1: SORT: Return BAD if sort program ends with REVERSE.
dovecot at dovecot.org
dovecot at dovecot.org
Sun Jul 13 20:13:33 EEST 2008
details: http://hg.dovecot.org/dovecot-1.1/rev/282b1ea973ef
changeset: 7754:282b1ea973ef
user: Timo Sirainen <tss at iki.fi>
date: Sun Jul 13 19:08:13 2008 +0300
description:
SORT: Return BAD if sort program ends with REVERSE.
diffstat:
1 file changed, 8 insertions(+), 4 deletions(-)
src/imap/cmd-sort.c | 12 ++++++++----
diffs (40 lines):
diff -r 5b53bd0d8f6d -r 282b1ea973ef src/imap/cmd-sort.c
--- a/src/imap/cmd-sort.c Sun Jul 13 18:16:21 2008 +0300
+++ b/src/imap/cmd-sort.c Sun Jul 13 19:08:13 2008 +0300
@@ -30,7 +30,7 @@ get_sort_program(struct client_command_c
{
enum mail_sort_type mask = 0;
unsigned int i, pos;
- bool reverse;
+ bool reverse, last_reverse;
if (args->type == IMAP_ARG_EOL) {
/* empyty list */
@@ -38,12 +38,13 @@ get_sort_program(struct client_command_c
return -1;
}
- pos = 0; reverse = FALSE;
+ pos = 0; reverse = last_reverse = FALSE;
for (; args->type == IMAP_ARG_ATOM || args->type == IMAP_ARG_STRING;
args++) {
const char *arg = IMAP_ARG_STR(args);
- if (strcasecmp(arg, "reverse") == 0) {
+ last_reverse = strcasecmp(arg, "reverse") == 0;
+ if (last_reverse) {
reverse = !reverse;
continue;
}
@@ -70,7 +71,10 @@ get_sort_program(struct client_command_c
(reverse ? MAIL_SORT_FLAG_REVERSE : 0);
reverse = FALSE;
}
-
+ if (last_reverse) {
+ client_send_command_error(cmd, "Sort list ends with REVERSE.");
+ return -1;
+ }
program[pos++] = MAIL_SORT_END;
if (args->type != IMAP_ARG_EOL) {
More information about the dovecot-cvs
mailing list