annotate auto/os/darwin @ 5418:6961d52ebc49 stable-1.4

Core: fix misallocation at ngx_crypt_apr1 (ticket #412). Found by using auth_basic.t from mdounin nginx-tests under valgrind. ==10470== Invalid write of size 1 ==10470== at 0x43603D: ngx_crypt_to64 (ngx_crypt.c:168) ==10470== by 0x43648E: ngx_crypt (ngx_crypt.c:153) ==10470== by 0x489D8B: ngx_http_auth_basic_crypt_handler (ngx_http_auth_basic_module.c:297) ==10470== by 0x48A24A: ngx_http_auth_basic_handler (ngx_http_auth_basic_module.c:240) ==10470== by 0x44EAB9: ngx_http_core_access_phase (ngx_http_core_module.c:1121) ==10470== by 0x44A822: ngx_http_core_run_phases (ngx_http_core_module.c:895) ==10470== by 0x44A932: ngx_http_handler (ngx_http_core_module.c:878) ==10470== by 0x455EEF: ngx_http_process_request (ngx_http_request.c:1852) ==10470== by 0x456527: ngx_http_process_request_headers (ngx_http_request.c:1283) ==10470== by 0x456A91: ngx_http_process_request_line (ngx_http_request.c:964) ==10470== by 0x457097: ngx_http_wait_request_handler (ngx_http_request.c:486) ==10470== by 0x4411EE: ngx_epoll_process_events (ngx_epoll_module.c:691) ==10470== Address 0x5866fab is 0 bytes after a block of size 27 alloc'd ==10470== at 0x4A074CD: malloc (vg_replace_malloc.c:236) ==10470== by 0x43B251: ngx_alloc (ngx_alloc.c:22) ==10470== by 0x421B0D: ngx_malloc (ngx_palloc.c:119) ==10470== by 0x421B65: ngx_pnalloc (ngx_palloc.c:147) ==10470== by 0x436368: ngx_crypt (ngx_crypt.c:140) ==10470== by 0x489D8B: ngx_http_auth_basic_crypt_handler (ngx_http_auth_basic_module.c:297) ==10470== by 0x48A24A: ngx_http_auth_basic_handler (ngx_http_auth_basic_module.c:240) ==10470== by 0x44EAB9: ngx_http_core_access_phase (ngx_http_core_module.c:1121) ==10470== by 0x44A822: ngx_http_core_run_phases (ngx_http_core_module.c:895) ==10470== by 0x44A932: ngx_http_handler (ngx_http_core_module.c:878) ==10470== by 0x455EEF: ngx_http_process_request (ngx_http_request.c:1852) ==10470== by 0x456527: ngx_http_process_request_headers (ngx_http_request.c:1283) ==10470==
author Markus Linnala <Markus.Linnala@cybercom.com>
date Fri, 20 Sep 2013 17:57:21 +0300
parents d620f497c50f
children 09d7faaef16f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2128
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
2 # Copyright (C) Igor Sysoev
4412
d620f497c50f Copyright updated.
Maxim Konovalov <maxim@nginx.com>
parents: 2128
diff changeset
3 # Copyright (C) Nginx, Inc.
2128
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
4
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
5
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
6 have=NGX_DARWIN . auto/have_headers
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
7
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
8 CORE_INCS="$UNIX_INCS"
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
9 CORE_DEPS="$UNIX_DEPS $DARWIN_DEPS"
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
10 CORE_SRCS="$UNIX_SRCS $DARWIN_SRCS"
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
11
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
12
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
13
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
14 ngx_spacer='
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
15 '
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
16
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
17 # kqueue
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
18
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
19 echo " + kqueue found"
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
20 have=NGX_HAVE_KQUEUE . auto/have
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
21 have=NGX_HAVE_CLEAR_EVENT . auto/have
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
22 EVENT_MODULES="$EVENT_MODULES $KQUEUE_MODULE"
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
23 CORE_SRCS="$CORE_SRCS $KQUEUE_SRCS"
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
24 EVENT_FOUND=YES
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
25 NGX_KQUEUE_CHECKED=YES
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
26
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
27 ngx_feature="kqueue's EVFILT_TIMER"
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
28 ngx_feature_name="NGX_HAVE_TIMER_EVENT"
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
29 ngx_feature_run=yes
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
30 ngx_feature_incs="#include <sys/event.h>
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
31 #include <sys/time.h>"
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
32 ngx_feature_path=
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
33 ngx_feature_libs=
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
34 ngx_feature_test="int kq;
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
35 struct kevent kev;
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
36 struct timespec ts;
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
37
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
38 if ((kq = kqueue()) == -1) return 1;
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
39
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
40 kev.ident = 0;
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
41 kev.filter = EVFILT_TIMER;
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
42 kev.flags = EV_ADD|EV_ENABLE;
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
43 kev.fflags = 0;
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
44 kev.data = 1000;
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
45 kev.udata = 0;
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
46
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
47 ts.tv_sec = 0;
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
48 ts.tv_nsec = 0;
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
49
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
50 if (kevent(kq, &kev, 1, &kev, 1, &ts) == -1) return 1;
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
51
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
52 if (kev.flags & EV_ERROR) return 1;"
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
53
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
54 . auto/feature
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
55
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
56
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
57 ngx_feature="Darwin 64-bit kqueue millisecond timeout bug"
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
58 ngx_feature_name=NGX_DARWIN_KEVENT_BUG
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
59 ngx_feature_run=bug
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
60 ngx_feature_incs="#include <sys/event.h>
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
61 #include <sys/time.h>"
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
62 ngx_feature_path=
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
63 ngx_feature_libs=
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
64 ngx_feature_test="int kq;
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
65 struct kevent kev;
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
66 struct timespec ts;
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
67 struct timeval tv, tv0;
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
68
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
69 kq = kqueue();
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
70
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
71 ts.tv_sec = 0;
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
72 ts.tv_nsec = 999000000;
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
73
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
74 gettimeofday(&tv, 0);
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
75 kevent(kq, NULL, 0, &kev, 1, &ts);
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
76 gettimeofday(&tv0, 0);
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
77 timersub(&tv0, &tv, &tv);
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
78
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
79 if (tv.tv_sec * 1000000 + tv.tv_usec < 900000) return 1;"
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
80
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
81 . auto/feature
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
82
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
83
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
84 # sendfile()
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
85
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
86 CC_AUX_FLAGS="$CC_AUX_FLAGS"
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
87 ngx_feature="sendfile()"
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
88 ngx_feature_name="NGX_HAVE_SENDFILE"
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
89 ngx_feature_run=yes
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
90 ngx_feature_incs="#include <sys/types.h>
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
91 #include <sys/socket.h>
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
92 #include <sys/uio.h>
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
93 #include <sys/errno.h>"
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
94 ngx_feature_path=
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
95 ngx_feature_libs=
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
96 ngx_feature_test="int s = 0, fd = 1;
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
97 off_t n; off_t off = 0;
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
98 n = sendfile(s, fd, off, &n, NULL, 0);
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
99 if (n == -1 && errno == ENOSYS) return 1"
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
100 . auto/feature
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
101
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
102 if [ $ngx_found = yes ]; then
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
103 have=NGX_HAVE_SENDFILE . auto/have
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
104 CORE_SRCS="$CORE_SRCS $DARWIN_SENDFILE_SRCS"
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
105 fi
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
106
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
107
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
108 ngx_feature="atomic(3)"
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
109 ngx_feature_name=NGX_DARWIN_ATOMIC
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
110 ngx_feature_run=no
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
111 ngx_feature_incs="#include <libkern/OSAtomic.h>"
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
112 ngx_feature_path=
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
113 ngx_feature_libs=
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
114 ngx_feature_test="int32_t lock, n;
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
115 n = OSAtomicCompareAndSwap32Barrier(0, 1, lock)"
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
116 . auto/feature