1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
|
# ./pullrev.sh 1891269 1891198 1891196
http://svn.apache.org/viewvc?view=revision&revision=1891269
http://svn.apache.org/viewvc?view=revision&revision=1891198
http://svn.apache.org/viewvc?view=revision&revision=1891196
--- apr-1.7.0/include/arch/unix/apr_arch_thread_mutex.h
+++ apr-1.7.0/include/arch/unix/apr_arch_thread_mutex.h
@@ -33,8 +33,10 @@
struct apr_thread_mutex_t {
apr_pool_t *pool;
pthread_mutex_t mutex;
+#ifndef HAVE_PTHREAD_MUTEX_TIMEDLOCK
apr_thread_cond_t *cond;
int locked, num_waiters;
+#endif
};
#endif
--- apr-1.7.0/locks/unix/thread_mutex.c
+++ apr-1.7.0/locks/unix/thread_mutex.c
@@ -102,6 +102,7 @@
{
apr_status_t rv;
+#ifndef HAVE_PTHREAD_MUTEX_TIMEDLOCK
if (mutex->cond) {
apr_status_t rv2;
@@ -133,6 +134,7 @@
return rv;
}
+#endif
rv = pthread_mutex_lock(&mutex->mutex);
#ifdef HAVE_ZOS_PTHREADS
@@ -148,6 +150,7 @@
{
apr_status_t rv;
+#ifndef HAVE_PTHREAD_MUTEX_TIMEDLOCK
if (mutex->cond) {
apr_status_t rv2;
@@ -177,6 +180,7 @@
return rv;
}
+#endif
rv = pthread_mutex_trylock(&mutex->mutex);
if (rv) {
@@ -281,6 +285,7 @@
{
apr_status_t status;
+#ifndef HAVE_PTHREAD_MUTEX_TIMEDLOCK
if (mutex->cond) {
status = pthread_mutex_lock(&mutex->mutex);
if (status) {
@@ -303,6 +308,7 @@
mutex->locked = 0;
}
+#endif
status = pthread_mutex_unlock(&mutex->mutex);
#ifdef HAVE_ZOS_PTHREADS
@@ -318,9 +324,12 @@
{
apr_status_t rv, rv2 = APR_SUCCESS;
+#ifndef HAVE_PTHREAD_MUTEX_TIMEDLOCK
if (mutex->cond) {
rv2 = apr_thread_cond_destroy(mutex->cond);
}
+#endif
+
rv = apr_pool_cleanup_run(mutex->pool, mutex, thread_mutex_cleanup);
if (rv == APR_SUCCESS) {
rv = rv2;
--- apr-1.7.0/random/unix/sha2.c
+++ apr-1.7.0/random/unix/sha2.c
@@ -425,7 +425,7 @@
usedspace = freespace = 0;
}
-void apr__SHA256_Final(sha2_byte digest[], SHA256_CTX* context) {
+void apr__SHA256_Final(sha2_byte digest[SHA256_DIGEST_LENGTH], SHA256_CTX* context) {
sha2_word32 *d = (sha2_word32*)digest;
unsigned int usedspace;
@@ -496,7 +496,7 @@
usedspace = 0;
}
-char *apr__SHA256_End(SHA256_CTX* context, char buffer[]) {
+char *apr__SHA256_End(SHA256_CTX* context, char buffer[SHA256_DIGEST_STRING_LENGTH]) {
sha2_byte digest[SHA256_DIGEST_LENGTH], *d = digest;
int i;
--- apr-1.7.0/time/unix/time.c
+++ apr-1.7.0/time/unix/time.c
@@ -142,6 +142,9 @@
static const int dayoffset[12] =
{306, 337, 0, 31, 61, 92, 122, 153, 184, 214, 245, 275};
+ if (xt->tm_mon < 0 || xt->tm_mon >= 12)
+ return APR_EBADDATE;
+
/* shift new year to 1st March in order to make leap year calc easy */
if (xt->tm_mon < 2)
--- apr-1.7.0/time/win32/time.c
+++ apr-1.7.0/time/win32/time.c
@@ -54,6 +54,9 @@
static const int dayoffset[12] =
{0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
+ if (tm->wMonth < 1 || tm->wMonth > 12)
+ return APR_EBADDATE;
+
/* Note; the caller is responsible for filling in detailed tm_usec,
* tm_gmtoff and tm_isdst data when applicable.
*/
@@ -228,6 +231,9 @@
static const int dayoffset[12] =
{306, 337, 0, 31, 61, 92, 122, 153, 184, 214, 245, 275};
+ if (xt->tm_mon < 0 || xt->tm_mon >= 12)
+ return APR_EBADDATE;
+
/* shift new year to 1st March in order to make leap year calc easy */
if (xt->tm_mon < 2)
--- apr-1.7.0/file_io/unix/readwrite.c
+++ apr-1.7.0/file_io/unix/readwrite.c
@@ -146,7 +146,7 @@
APR_DECLARE(apr_status_t) apr_file_write(apr_file_t *thefile, const void *buf, apr_size_t *nbytes)
{
- apr_size_t rv;
+ apr_size_t rv = APR_SUCCESS;
if (thefile->buffered) {
char *pos = (char *)buf;
@@ -160,13 +160,14 @@
* logically reading from
*/
apr_int64_t offset = thefile->filePtr - thefile->dataRead + thefile->bufpos;
- if (offset != thefile->filePtr)
- lseek(thefile->filedes, offset, SEEK_SET);
+ if (offset != thefile->filePtr) {
+ thefile->filePtr = lseek(thefile->filedes, offset, SEEK_SET);
+ if (thefile->filePtr == -1) rv = errno;
+ }
thefile->bufpos = thefile->dataRead = 0;
thefile->direction = 1;
}
- rv = 0;
while (rv == 0 && size > 0) {
if (thefile->bufpos == thefile->bufsize) /* write buffer is full*/
rv = apr_file_flush_locked(thefile);
@@ -244,12 +245,15 @@
*/
apr_int64_t offset = thefile->filePtr - thefile->dataRead +
thefile->bufpos;
- if (offset != thefile->filePtr)
- lseek(thefile->filedes, offset, SEEK_SET);
+ if (offset != thefile->filePtr) {
+ thefile->filePtr = lseek(thefile->filedes, offset, SEEK_SET);
+ if (thefile->filePtr == -1) rv = errno;
+ }
thefile->bufpos = thefile->dataRead = 0;
}
file_unlock(thefile);
+ if (rv) return rv;
}
if ((bytes = writev(thefile->filedes, vec, nvec)) < 0) {
--- apr-1.7.0/locks/unix/proc_mutex.c
+++ apr-1.7.0/locks/unix/proc_mutex.c
@@ -1518,11 +1518,10 @@
APR_DECLARE(const char *) apr_proc_mutex_defname(void)
{
- apr_status_t rv;
apr_proc_mutex_t mutex;
- if ((rv = proc_mutex_choose_method(&mutex, APR_LOCK_DEFAULT,
- NULL)) != APR_SUCCESS) {
+ if (proc_mutex_choose_method(&mutex, APR_LOCK_DEFAULT,
+ NULL) != APR_SUCCESS) {
return "unknown";
}
--- apr-1.7.0/memory/unix/apr_pools.c
+++ apr-1.7.0/memory/unix/apr_pools.c
@@ -1338,7 +1338,7 @@
apr_size_t free_index;
pool_concurrency_set_used(pool);
- ps.node = active = pool->active;
+ ps.node = pool->active;
ps.pool = pool;
ps.vbuff.curpos = ps.node->first_avail;
--- apr-1.7.0/test/teststr.c
+++ apr-1.7.0/test/teststr.c
@@ -394,6 +394,19 @@
ABTS_STR_EQUAL(tc, apr_cstr_skip_prefix("", "12"), NULL);
}
+static void pstrcat(abts_case *tc, void *data)
+{
+ ABTS_STR_EQUAL(tc, apr_pstrcat(p, "a", "bc", "def", NULL),
+ "abcdef");
+ ABTS_STR_EQUAL(tc, apr_pstrcat(p, NULL), "");
+ ABTS_STR_EQUAL(tc, apr_pstrcat(p,
+ "a", "b", "c", "d", "e",
+ "f", "g", "h", "i", "j",
+ "1", "2", "3", "4", "5",
+ NULL),
+ "abcdefghij12345");
+}
+
abts_suite *teststr(abts_suite *suite)
{
suite = ADD_SUITE(suite)
@@ -412,6 +425,7 @@
abts_run_test(suite, string_cpystrn, NULL);
abts_run_test(suite, snprintf_overflow, NULL);
abts_run_test(suite, skip_prefix, NULL);
+ abts_run_test(suite, pstrcat, NULL);
return suite;
}
|