annotate auto/cc/ccc @ 8460:3974f4e56a4e

Mail: fixed s->arg_start clearing on invalid IMAP commands. Previously, s->arg_start was left intact after invalid IMAP commands, and this might result in an argument incorrectly added to the following command. Similarly, s->backslash was left intact as well, leading to unneeded backslash removal. For example (LFs from the client are explicitly shown as "<LF>"): S: * OK IMAP4 ready C: a01 login "\<LF> S: a01 BAD invalid command C: a0000000000\2 authenticate <LF> S: a00000000002 aBAD invalid command The backslash followed by LF generates invalid command with s->arg_start and s->backslash set, the following command incorrectly treats anything from the old s->arg_start to the space after the command as an argument, and removes the backslash from the tag. If there is no space, s->arg_end will be NULL. Both things seem to be harmless though. In particular: - This can be used to provide an incorrect argument to a command without arguments. The only command which seems to look at the single argument is AUTHENTICATE, and it checks the argument length before trying to access it. - Backslash removal uses the "end" pointer, and stops due to "src < end" condition instead of scanning all the process memory if s->arg_end is NULL (and arg[0].len is huge). - There should be no backslashes in unquoted strings. An obvious fix is to clear s->arg_start and s->backslash on invalid commands, similarly to how it is done in POP3 parsing (added in 810:e3aa8f305d21) and SMTP parsing. This, however, makes it clear that s->arg_start handling in the "done" label is wrong: s->arg_start cannot be legitimately set there, as it is expected to be cleared in all possible cases when the "done" label is reached. The relevant code is dead and will be removed by the following change.
author Maxim Dounin <mdounin@mdounin.ru>
date Wed, 19 May 2021 03:13:20 +0300
parents d620f497c50f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
515
417a087c9c4d nginx-0.1.32-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1
417a087c9c4d nginx-0.1.32-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
2 # Copyright (C) Igor Sysoev
4412
d620f497c50f Copyright updated.
Maxim Konovalov <maxim@nginx.com>
parents: 517
diff changeset
3 # Copyright (C) Nginx, Inc.
515
417a087c9c4d nginx-0.1.32-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
4
417a087c9c4d nginx-0.1.32-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
5
417a087c9c4d nginx-0.1.32-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
6 # Compaq C V6.5-207
417a087c9c4d nginx-0.1.32-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
7
417a087c9c4d nginx-0.1.32-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
8 ngx_include_opt="-I"
417a087c9c4d nginx-0.1.32-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
9
417a087c9c4d nginx-0.1.32-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
10 # warnings
417a087c9c4d nginx-0.1.32-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
11
417a087c9c4d nginx-0.1.32-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
12 CFLAGS="$CFLAGS -msg_enable level6 -msg_fatal level6"
417a087c9c4d nginx-0.1.32-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
13
517
dadfa78d2270 nginx-0.1.33-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 515
diff changeset
14 CFLAGS="$CFLAGS -msg_disable unknownmacro"
dadfa78d2270 nginx-0.1.33-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 515
diff changeset
15 CFLAGS="$CFLAGS -msg_disable unusedincl"
515
417a087c9c4d nginx-0.1.32-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
16 CFLAGS="$CFLAGS -msg_disable unnecincl"
417a087c9c4d nginx-0.1.32-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
17 CFLAGS="$CFLAGS -msg_disable nestincl"
417a087c9c4d nginx-0.1.32-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
18 CFLAGS="$CFLAGS -msg_disable strctpadding"
417a087c9c4d nginx-0.1.32-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
19 CFLAGS="$CFLAGS -msg_disable ansialiascast"
417a087c9c4d nginx-0.1.32-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
20 CFLAGS="$CFLAGS -msg_disable inlinestoclsmod"
417a087c9c4d nginx-0.1.32-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
21 CFLAGS="$CFLAGS -msg_disable cxxkeyword"
417a087c9c4d nginx-0.1.32-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
22 CFLAGS="$CFLAGS -msg_disable longlongsufx"
517
dadfa78d2270 nginx-0.1.33-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 515
diff changeset
23 CFLAGS="$CFLAGS -msg_disable valuepres"
515
417a087c9c4d nginx-0.1.32-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
24
417a087c9c4d nginx-0.1.32-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
25 # STUB
417a087c9c4d nginx-0.1.32-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
26 CFLAGS="$CFLAGS -msg_disable truncintcast"
417a087c9c4d nginx-0.1.32-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
27 CFLAGS="$CFLAGS -msg_disable trunclongcast"
517
dadfa78d2270 nginx-0.1.33-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 515
diff changeset
28
515
417a087c9c4d nginx-0.1.32-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
29 CFLAGS="$CFLAGS -msg_disable truncintasn"
417a087c9c4d nginx-0.1.32-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
30 CFLAGS="$CFLAGS -msg_disable trunclongint"
417a087c9c4d nginx-0.1.32-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
31 CFLAGS="$CFLAGS -msg_disable intconcastsgn"
417a087c9c4d nginx-0.1.32-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
32 CFLAGS="$CFLAGS -msg_disable intconstsign"
517
dadfa78d2270 nginx-0.1.33-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 515
diff changeset
33 CFLAGS="$CFLAGS -msg_disable switchlong"
dadfa78d2270 nginx-0.1.33-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 515
diff changeset
34 CFLAGS="$CFLAGS -msg_disable subscrbounds2"
dadfa78d2270 nginx-0.1.33-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 515
diff changeset
35
515
417a087c9c4d nginx-0.1.32-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
36 CFLAGS="$CFLAGS -msg_disable hexoctunsign"
517
dadfa78d2270 nginx-0.1.33-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 515
diff changeset
37
515
417a087c9c4d nginx-0.1.32-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
38 CFLAGS="$CFLAGS -msg_disable ignorecallval"
417a087c9c4d nginx-0.1.32-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
39 CFLAGS="$CFLAGS -msg_disable nonstandcast"
417a087c9c4d nginx-0.1.32-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
40 CFLAGS="$CFLAGS -msg_disable embedcomment"
417a087c9c4d nginx-0.1.32-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
41 CFLAGS="$CFLAGS -msg_disable unreachcode"
417a087c9c4d nginx-0.1.32-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
42 CFLAGS="$CFLAGS -msg_disable questcompare2"
417a087c9c4d nginx-0.1.32-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
43 CFLAGS="$CFLAGS -msg_disable unusedtop"
417a087c9c4d nginx-0.1.32-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
44 CFLAGS="$CFLAGS -msg_disable unrefdecl"
517
dadfa78d2270 nginx-0.1.33-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 515
diff changeset
45
515
417a087c9c4d nginx-0.1.32-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
46 CFLAGS="$CFLAGS -msg_disable bitnotint"