Mercurial > hg > nginx-quic
annotate auto/init @ 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 | 549b13cd793b |
children |
rev | line source |
---|---|
444
42d11f017717
nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
1 |
42d11f017717
nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
2 # Copyright (C) Igor Sysoev |
4412 | 3 # Copyright (C) Nginx, Inc. |
444
42d11f017717
nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents:
297
diff
changeset
|
4 |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
5 |
455 | 6 NGX_MAKEFILE=$NGX_OBJS/Makefile |
7 NGX_MODULES_C=$NGX_OBJS/ngx_modules.c | |
8 | |
9 NGX_AUTO_HEADERS_H=$NGX_OBJS/ngx_auto_headers.h | |
10 NGX_AUTO_CONFIG_H=$NGX_OBJS/ngx_auto_config.h | |
11 | |
12 NGX_AUTOTEST=$NGX_OBJS/autotest | |
13 NGX_AUTOCONF_ERR=$NGX_OBJS/autoconf.err | |
14 | |
15 # STUBs | |
469 | 16 NGX_ERR=$NGX_OBJS/autoconf.err |
17 MAKEFILE=$NGX_OBJS/Makefile | |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
18 |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
19 |
455 | 20 NGX_PCH= |
21 NGX_USE_PCH= | |
280
7c7183b3ea8b
nginx-0.0.2-2004-03-05-11:34:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
254
diff
changeset
|
22 |
7c7183b3ea8b
nginx-0.0.2-2004-03-05-11:34:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
254
diff
changeset
|
23 |
455 | 24 # check the echo's "-n" option and "\c" capability |
250
1903c6821958
nginx-0.0.2-2004-02-03-23:27:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
210
diff
changeset
|
25 |
1903c6821958
nginx-0.0.2-2004-02-03-23:27:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
210
diff
changeset
|
26 if echo "test\c" | grep c >/dev/null; then |
455 | 27 |
250
1903c6821958
nginx-0.0.2-2004-02-03-23:27:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
210
diff
changeset
|
28 if echo -n test | grep n >/dev/null; then |
1903c6821958
nginx-0.0.2-2004-02-03-23:27:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
210
diff
changeset
|
29 ngx_n= |
1903c6821958
nginx-0.0.2-2004-02-03-23:27:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
210
diff
changeset
|
30 ngx_c= |
455 | 31 |
250
1903c6821958
nginx-0.0.2-2004-02-03-23:27:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
210
diff
changeset
|
32 else |
1903c6821958
nginx-0.0.2-2004-02-03-23:27:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
210
diff
changeset
|
33 ngx_n=-n |
1903c6821958
nginx-0.0.2-2004-02-03-23:27:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
210
diff
changeset
|
34 ngx_c= |
1903c6821958
nginx-0.0.2-2004-02-03-23:27:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
210
diff
changeset
|
35 fi |
1903c6821958
nginx-0.0.2-2004-02-03-23:27:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
210
diff
changeset
|
36 |
1903c6821958
nginx-0.0.2-2004-02-03-23:27:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
210
diff
changeset
|
37 else |
1903c6821958
nginx-0.0.2-2004-02-03-23:27:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
210
diff
changeset
|
38 ngx_n= |
1903c6821958
nginx-0.0.2-2004-02-03-23:27:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
210
diff
changeset
|
39 ngx_c='\c' |
1903c6821958
nginx-0.0.2-2004-02-03-23:27:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
210
diff
changeset
|
40 fi |
452 | 41 |
42 | |
455 | 43 # create Makefile |
452 | 44 |
455 | 45 cat << END > Makefile |
452 | 46 |
2850
4e05bd832e56
fix "make upgrade" broken in r2759
Igor Sysoev <igor@sysoev.ru>
parents:
1393
diff
changeset
|
47 default: build |
452 | 48 |
49 clean: | |
455 | 50 rm -rf Makefile $NGX_OBJS |
8327
549b13cd793b
Configure: marked top-level make targets as phony.
Ruslan Ermilov <ru@nginx.com>
parents:
6425
diff
changeset
|
51 |
549b13cd793b
Configure: marked top-level make targets as phony.
Ruslan Ermilov <ru@nginx.com>
parents:
6425
diff
changeset
|
52 .PHONY: default clean |
452 | 53 END |