Mercurial > hg > nginx
annotate src/os/win32/ngx_errno.c @ 9300:5be23505292b default tip
SSI: fixed incorrect or duplicate stub output.
Following 3518:eb3aaf8bd2a9 (0.8.37), r->request_output is only set
if there are data in the first buffer sent in the subrequest. As a
result, following the change mentioned this flag cannot be used to
prevent duplicate ngx_http_ssi_stub_output() calls, since it is not
set if there was already some output, but the first buffer was empty.
Still, when there are multiple subrequests, even an empty subrequest
response might be delayed by the postpone filter, leading to a second
call of ngx_http_ssi_stub_output() during finalization from
ngx_http_writer() the subreqest buffers are released by the postpone
filter. Since r->request_output is not set after the first call, this
resulted in duplicate stub output.
Additionally, checking only the first buffer might be wrong in some
unusual cases. For example, the first buffer might be empty if
$r->flush() is called before printing any data in the embedded Perl
module.
Depending on the postpone_output value and corresponding sizes, this
issue can result in either duplicate or unexpected stub output, or
"zero size buf in writer" alerts.
Following 8124:f5515e727656 (1.23.4), it became slightly easier to
reproduce the issue, as empty static files and empty cache items now
result in a response with an empty buffer. Before the change, an empty
proxied response can be used to reproduce the issue.
Fix is check all buffers and set r->request_output if any non-empty
buffers are sent. This ensures that all unusual cases of non-empty
responses are covered, and also that r->request_output will be set
after the first stub output, preventing duplicate output.
Reported by Jan Gassen.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 04 Jul 2024 17:41:28 +0300 |
parents | 746567d633ac |
children |
rev | line source |
---|---|
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1 |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
2 /* |
444
42d11f017717
nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
3 * Copyright (C) Igor Sysoev |
4412 | 4 * Copyright (C) Nginx, Inc. |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
186
diff
changeset
|
5 */ |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
186
diff
changeset
|
6 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
186
diff
changeset
|
7 |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #include <ngx_config.h> |
98
c9b243802a17
nginx-0.0.1-2003-05-30-18:27:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
0
diff
changeset
|
9 #include <ngx_core.h> |
c9b243802a17
nginx-0.0.1-2003-05-30-18:27:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
0
diff
changeset
|
10 |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
11 |
2335
3d8ab5957202
ngx_strerror_r() style and size == 0 bug fix
Igor Sysoev <igor@sysoev.ru>
parents:
473
diff
changeset
|
12 u_char * |
3787
e294f37401c0
use copied strerror() messages and autoconfigured sys_nerr value
Igor Sysoev <igor@sysoev.ru>
parents:
2770
diff
changeset
|
13 ngx_strerror(ngx_err_t err, u_char *errstr, size_t size) |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
14 { |
2770
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
15 u_int len; |
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
16 static u_long lang = MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US); |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
17 |
461 | 18 if (size == 0) { |
19 return errstr; | |
20 } | |
21 | |
2770
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
22 len = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, |
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
23 NULL, err, lang, (char *) errstr, size, NULL); |
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
24 |
7585
746567d633ac
Win32: improved fallback on FormatMessage() errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4693
diff
changeset
|
25 if (len == 0 && lang) { |
2770
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
26 |
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
27 /* |
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
28 * Try to use English messages first and fallback to a language, |
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
29 * based on locale: non-English Windows have no English messages |
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
30 * at all. This way allows to use English messages at least on |
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
31 * Windows with MUI. |
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
32 */ |
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
33 |
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
34 lang = 0; |
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
35 |
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
36 len = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, |
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
37 NULL, err, lang, (char *) errstr, size, NULL); |
e70ac6e13f31
fallback to neutral language in FormatMessage()
Igor Sysoev <igor@sysoev.ru>
parents:
2766
diff
changeset
|
38 } |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
39 |
103
6dfda4cf5200
nginx-0.0.1-2003-06-11-19:28:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
98
diff
changeset
|
40 if (len == 0) { |
461 | 41 return ngx_snprintf(errstr, size, |
2740
e5a4be07c3eb
axe incomplete support of Winsock error descriptions on NT
Igor Sysoev <igor@sysoev.ru>
parents:
2739
diff
changeset
|
42 "FormatMessage() error:(%d)", GetLastError()); |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
43 } |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
44 |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
45 /* remove ".\r\n\0" */ |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
46 while (errstr[len] == '\0' || errstr[len] == CR |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
47 || errstr[len] == LF || errstr[len] == '.') |
461 | 48 { |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
49 --len; |
461 | 50 } |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
51 |
461 | 52 return &errstr[++len]; |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
53 } |
3787
e294f37401c0
use copied strerror() messages and autoconfigured sys_nerr value
Igor Sysoev <igor@sysoev.ru>
parents:
2770
diff
changeset
|
54 |
e294f37401c0
use copied strerror() messages and autoconfigured sys_nerr value
Igor Sysoev <igor@sysoev.ru>
parents:
2770
diff
changeset
|
55 |
4693
f1a0de6eb505
Fixed return type of ngx_strerror_init().
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
56 ngx_int_t |
3787
e294f37401c0
use copied strerror() messages and autoconfigured sys_nerr value
Igor Sysoev <igor@sysoev.ru>
parents:
2770
diff
changeset
|
57 ngx_strerror_init(void) |
e294f37401c0
use copied strerror() messages and autoconfigured sys_nerr value
Igor Sysoev <igor@sysoev.ru>
parents:
2770
diff
changeset
|
58 { |
e294f37401c0
use copied strerror() messages and autoconfigured sys_nerr value
Igor Sysoev <igor@sysoev.ru>
parents:
2770
diff
changeset
|
59 return NGX_OK; |
e294f37401c0
use copied strerror() messages and autoconfigured sys_nerr value
Igor Sysoev <igor@sysoev.ru>
parents:
2770
diff
changeset
|
60 } |