|
Line 0
Link Here
|
|
|
1 |
NOTIFY was broken since 2.2.31, and this patch reverts that breakage, using two |
| 2 |
upstream commits: |
| 3 |
|
| 4 |
* https://github.com/dovecot/core/commit/bcb321bc62117d30bc53a872ca1154c0100aeefd |
| 5 |
* https://github.com/dovecot/core/commit/8b2d740b8182c63b76ff7ef0dd5e01710228705a |
| 6 |
|
| 7 |
From bcb321bc62117d30bc53a872ca1154c0100aeefd Mon Sep 17 00:00:00 2001 |
| 8 |
From: Timo Sirainen <timo.sirainen@dovecot.fi> |
| 9 |
Date: Fri, 30 Jun 2017 17:33:15 +0300 |
| 10 |
Subject: [PATCH] imap: Fix NOTIFY parameter parsing by reverting earlier |
| 11 |
change |
| 12 |
|
| 13 |
I misread the RFC and wrote broken tests. |
| 14 |
Reverts 64d2efdc4b0bdf92249840e9db89b91c8dc0f3a3 |
| 15 |
|
| 16 |
|
| 17 |
From 8b2d740b8182c63b76ff7ef0dd5e01710228705a Mon Sep 17 00:00:00 2001 |
| 18 |
From: Timo Sirainen <timo.sirainen@dovecot.fi> |
| 19 |
Date: Fri, 30 Jun 2017 17:51:34 +0300 |
| 20 |
Subject: [PATCH] imap: Add more error checking to NOTIFY parameter parsing |
| 21 |
|
| 22 |
This should make it clearer to realize when invalid syntax is being used |
| 23 |
rather than just ignoring the problem. |
| 24 |
|
| 25 |
|
| 26 |
--- src/imap/cmd-notify.c.orig 2017-06-30 21:31:28 UTC |
| 27 |
+++ src/imap/cmd-notify.c |
| 28 |
@@ -41,6 +41,8 @@ static int |
| 29 |
cmd_notify_parse_fetch(struct imap_notify_context *ctx, |
| 30 |
const struct imap_arg *list) |
| 31 |
{ |
| 32 |
+ if (list->type == IMAP_ARG_EOL) |
| 33 |
+ return -1; /* at least one attribute must be set */ |
| 34 |
return imap_fetch_att_list_parse(ctx->client, ctx->pool, list, |
| 35 |
&ctx->fetch_ctx, &ctx->error); |
| 36 |
} |
| 37 |
@@ -59,11 +61,17 @@ cmd_notify_set_selected(struct imap_noti |
| 38 |
strcasecmp(str, "NONE") == 0) { |
| 39 |
/* no events for selected mailbox. this is also the default |
| 40 |
when NOTIFY command doesn't specify it explicitly */ |
| 41 |
+ if (events[1].type != IMAP_ARG_EOL) |
| 42 |
+ return -1; /* no extra parameters */ |
| 43 |
return 0; |
| 44 |
} |
| 45 |
|
| 46 |
if (!imap_arg_get_list(events, &list)) |
| 47 |
return -1; |
| 48 |
+ if (events[1].type != IMAP_ARG_EOL) |
| 49 |
+ return -1; /* no extra parameters */ |
| 50 |
+ if (list->type == IMAP_ARG_EOL) |
| 51 |
+ return -1; /* at least one event */ |
| 52 |
|
| 53 |
for (; list->type != IMAP_ARG_EOL; list++) { |
| 54 |
if (cmd_notify_parse_event(list, &event) < 0) |
| 55 |
@@ -292,10 +300,10 @@ cmd_notify_set(struct imap_notify_contex |
| 56 |
ctx->send_immediate_status = TRUE; |
| 57 |
args++; |
| 58 |
} |
| 59 |
+ for (; args->type != IMAP_ARG_EOL; args++) { |
| 60 |
+ if (!imap_arg_get_list(args, &event_group)) |
| 61 |
+ return -1; |
| 62 |
|
| 63 |
- if (!imap_arg_get_list(args, &event_group)) |
| 64 |
- return -1; |
| 65 |
- for (; event_group->type != IMAP_ARG_EOL; event_group++) { |
| 66 |
/* filter-mailboxes */ |
| 67 |
if (!imap_arg_get_atom(event_group, &filter_mailboxes)) |
| 68 |
return -1; |
| 69 |
@@ -322,6 +330,15 @@ cmd_notify_set(struct imap_notify_contex |
| 70 |
if (event_group->type == IMAP_ARG_EOL) |
| 71 |
return -1; |
| 72 |
mailboxes = event_group++; |
| 73 |
+ /* check that the mailboxes parameter is valid */ |
| 74 |
+ if (IMAP_ARG_IS_ASTRING(mailboxes)) |
| 75 |
+ ; |
| 76 |
+ else if (!imap_arg_get_list(mailboxes, &list)) |
| 77 |
+ return -1; |
| 78 |
+ else if (list->type == IMAP_ARG_EOL) { |
| 79 |
+ /* should have at least one mailbox */ |
| 80 |
+ return -1; |
| 81 |
+ } |
| 82 |
} else { |
| 83 |
mailboxes = NULL; |
| 84 |
} |