Mercurial > hg > nginx
annotate auto/types/uintptr_t @ 7054:e02555553d0b
Range filter: protect from total size overflows.
The overflow can be used to circumvent the restriction on total size of
ranges introduced in c2a91088b0c0 (1.1.2). Additionally, overflow
allows producing ranges with negative start (such ranges can be created
by using a suffix, "bytes=-100"; normally this results in 200 due to
the total size check). These can result in the following errors in logs:
[crit] ... pread() ... failed (22: Invalid argument)
[alert] ... sendfile() failed (22: Invalid argument)
When using cache, it can be also used to reveal cache file header.
It is believed that there are no other negative effects, at least with
standard nginx modules.
In theory, this can also result in memory disclosure and/or segmentation
faults if multiple ranges are allowed, and the response is returned in a
single in-memory buffer. This never happens with standard nginx modules
though, as well as known 3rd party modules.
Fix is to properly protect from possible overflow when incrementing size.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Tue, 11 Jul 2017 16:06:23 +0300 |
parents | a616bdc38645 |
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:
370
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:
370
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:
370
diff
changeset
|
4 |
192
31824be1fc66
nginx-0.0.1-2003-11-20-10:05:50 import; auto/configure
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
5 |
455 | 6 echo $ngx_n "checking for uintptr_t ...$ngx_c" |
6269
7ec809b579d7
Configure: style fixes for autoconf.err.
Piotr Sikora <piotrsikora@google.com>
parents:
5309
diff
changeset
|
7 |
7ec809b579d7
Configure: style fixes for autoconf.err.
Piotr Sikora <piotrsikora@google.com>
parents:
5309
diff
changeset
|
8 cat << END >> $NGX_AUTOCONF_ERR |
7ec809b579d7
Configure: style fixes for autoconf.err.
Piotr Sikora <piotrsikora@google.com>
parents:
5309
diff
changeset
|
9 |
7ec809b579d7
Configure: style fixes for autoconf.err.
Piotr Sikora <piotrsikora@google.com>
parents:
5309
diff
changeset
|
10 ---------------------------------------- |
7ec809b579d7
Configure: style fixes for autoconf.err.
Piotr Sikora <piotrsikora@google.com>
parents:
5309
diff
changeset
|
11 checking for uintptr_t |
7ec809b579d7
Configure: style fixes for autoconf.err.
Piotr Sikora <piotrsikora@google.com>
parents:
5309
diff
changeset
|
12 |
7ec809b579d7
Configure: style fixes for autoconf.err.
Piotr Sikora <piotrsikora@google.com>
parents:
5309
diff
changeset
|
13 END |
192
31824be1fc66
nginx-0.0.1-2003-11-20-10:05:50 import; auto/configure
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
14 |
210
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
196
diff
changeset
|
15 found=no |
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
196
diff
changeset
|
16 |
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
196
diff
changeset
|
17 cat << END > $NGX_AUTOTEST.c |
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
196
diff
changeset
|
18 |
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
196
diff
changeset
|
19 #include <sys/types.h> |
6625
a616bdc38645
Configure: stop polluting NGX_ namespace.
Piotr Sikora <piotrsikora@google.com>
parents:
6624
diff
changeset
|
20 $NGX_INCLUDE_INTTYPES_H |
192
31824be1fc66
nginx-0.0.1-2003-11-20-10:05:50 import; auto/configure
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
21 |
6624
e3faa5fb7772
Configure: fix build with -Werror=old-style-definition.
Piotr Sikora <piotrsikora@google.com>
parents:
6269
diff
changeset
|
22 int main(void) { |
4559
62d8db8c7157
Fixed more gcc46 warnings in configure tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4543
diff
changeset
|
23 uintptr_t i = 0; |
62d8db8c7157
Fixed more gcc46 warnings in configure tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4543
diff
changeset
|
24 return (int) i; |
210
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
196
diff
changeset
|
25 } |
192
31824be1fc66
nginx-0.0.1-2003-11-20-10:05:50 import; auto/configure
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
26 |
210
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
196
diff
changeset
|
27 END |
192
31824be1fc66
nginx-0.0.1-2003-11-20-10:05:50 import; auto/configure
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
28 |
4543
51744fa997c7
Fixed compilation warnings in configuration C tests.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
29 ngx_test="$CC $CC_TEST_FLAGS $CC_AUX_FLAGS \ |
51744fa997c7
Fixed compilation warnings in configuration C tests.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
30 -o $NGX_AUTOTEST $NGX_AUTOTEST.c $NGX_LD_OPT" |
51744fa997c7
Fixed compilation warnings in configuration C tests.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
31 |
51744fa997c7
Fixed compilation warnings in configuration C tests.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
32 eval "$ngx_test >> $NGX_AUTOCONF_ERR 2>&1" |
210
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
196
diff
changeset
|
33 |
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
196
diff
changeset
|
34 if [ -x $NGX_AUTOTEST ]; then |
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
196
diff
changeset
|
35 echo " uintptr_t found" |
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
196
diff
changeset
|
36 found=yes |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
193
diff
changeset
|
37 else |
250
1903c6821958
nginx-0.0.2-2004-02-03-23:27:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
210
diff
changeset
|
38 echo $ngx_n " uintptr_t not found" $ngx_c |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
193
diff
changeset
|
39 fi |
192
31824be1fc66
nginx-0.0.1-2003-11-20-10:05:50 import; auto/configure
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
40 |
5309
434548349838
Configure: fixed autotest cleanup commands.
Sergey Kandaurov <pluknet@nginx.com>
parents:
4559
diff
changeset
|
41 rm -rf $NGX_AUTOTEST* |
192
31824be1fc66
nginx-0.0.1-2003-11-20-10:05:50 import; auto/configure
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
42 |
31824be1fc66
nginx-0.0.1-2003-11-20-10:05:50 import; auto/configure
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
43 |
210
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
196
diff
changeset
|
44 if [ $found = no ]; then |
370
54f76b0b8dca
nginx-0.0.7-2004-06-27-22:01:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
250
diff
changeset
|
45 found="uint`expr 8 \* $ngx_ptr_size`_t" |
210
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
196
diff
changeset
|
46 echo ", $found used" |
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
196
diff
changeset
|
47 |
1354
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
455
diff
changeset
|
48 echo "typedef $found uintptr_t;" >> $NGX_AUTO_CONFIG_H |
f69d1aab6a0f
make 64-bit ngx_int_t on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
455
diff
changeset
|
49 echo "typedef $found intptr_t;" | sed -e 's/u//g' >> $NGX_AUTO_CONFIG_H |
192
31824be1fc66
nginx-0.0.1-2003-11-20-10:05:50 import; auto/configure
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
50 fi |