|
@@ -1,754 +0,0 @@
|
1
|
|
---- a/ChangeLog
|
2
|
|
-+++ b/ChangeLog
|
3
|
|
-@@ -1,3 +1,14 @@
|
4
|
|
-+Thu Jun 4 13:37:05 CEST 2015
|
5
|
|
-+ Fixing memory leak in digest authentication. -AW
|
6
|
|
-+
|
7
|
|
-+Wed Jun 03 21:23:47 CEST 2015
|
8
|
|
-+ Add deprecation compiler messages for deprecated functions
|
9
|
|
-+ and macros. -EG
|
10
|
|
-+
|
11
|
|
-+Fri May 29 12:23:01 CEST 2015
|
12
|
|
-+ Fixing digest authentication when used in combination
|
13
|
|
-+ with escaped characters in URLs. -CG/AW
|
14
|
|
-+
|
15
|
|
- Wed May 13 11:49:09 CEST 2015
|
16
|
|
- Releasing libmicrohttpd 0.9.42. -CG
|
17
|
|
-
|
18
|
|
---- a/src/microhttpd/response.c
|
19
|
|
-+++ b/src/microhttpd/response.c
|
20
|
|
-@@ -24,6 +24,8 @@
|
21
|
|
- * @author Christian Grothoff
|
22
|
|
- */
|
23
|
|
-
|
24
|
|
-+#define MHD_NO_DEPRECATION 1
|
25
|
|
-+
|
26
|
|
- #include "internal.h"
|
27
|
|
- #include "response.h"
|
28
|
|
-
|
29
|
|
---- a/src/microhttpd/digestauth.c
|
30
|
|
-+++ b/src/microhttpd/digestauth.c
|
31
|
|
-@@ -1,6 +1,6 @@
|
32
|
|
- /*
|
33
|
|
- This file is part of libmicrohttpd
|
34
|
|
-- Copyright (C) 2010, 2011, 2012 Daniel Pittman and Christian Grothoff
|
35
|
|
-+ Copyright (C) 2010, 2011, 2012, 2015 Daniel Pittman and Christian Grothoff
|
36
|
|
-
|
37
|
|
- This library is free software; you can redistribute it and/or
|
38
|
|
- modify it under the terms of the GNU Lesser General Public
|
39
|
|
-@@ -472,8 +472,8 @@ test_header (struct MHD_Connection *conn
|
40
|
|
- *
|
41
|
|
- * @param connection connections with headers to compare against
|
42
|
|
- * @param args argument URI string (after "?" in URI)
|
43
|
|
-- * @return MHD_YES if the arguments match,
|
44
|
|
-- * MHD_NO if not
|
45
|
|
-+ * @return #MHD_YES if the arguments match,
|
46
|
|
-+ * #MHD_NO if not
|
47
|
|
- */
|
48
|
|
- static int
|
49
|
|
- check_argument_match (struct MHD_Connection *connection,
|
50
|
|
-@@ -508,7 +508,10 @@ check_argument_match (struct MHD_Connect
|
51
|
|
- connection,
|
52
|
|
- argp);
|
53
|
|
- if (MHD_YES != test_header (connection, argp, NULL))
|
54
|
|
-- return MHD_NO;
|
55
|
|
-+ {
|
56
|
|
-+ free(argb);
|
57
|
|
-+ return MHD_NO;
|
58
|
|
-+ }
|
59
|
|
- num_headers++;
|
60
|
|
- break;
|
61
|
|
- }
|
62
|
|
-@@ -527,10 +530,16 @@ check_argument_match (struct MHD_Connect
|
63
|
|
- connection,
|
64
|
|
- equals);
|
65
|
|
- if (! test_header (connection, argp, equals))
|
66
|
|
-- return MHD_NO;
|
67
|
|
-+ {
|
68
|
|
-+ free(argb);
|
69
|
|
-+ return MHD_NO;
|
70
|
|
-+ }
|
71
|
|
-+
|
72
|
|
- num_headers++;
|
73
|
|
- argp = amper;
|
74
|
|
- }
|
75
|
|
-+
|
76
|
|
-+ free(argb);
|
77
|
|
-
|
78
|
|
- /* also check that the number of headers matches */
|
79
|
|
- for (pos = connection->headers_received; NULL != pos; pos = pos->next)
|
80
|
|
-@@ -632,10 +641,83 @@ MHD_digest_auth_check (struct MHD_Connec
|
81
|
|
- header value. */
|
82
|
|
- return MHD_NO;
|
83
|
|
- }
|
84
|
|
-+ /* 8 = 4 hexadecimal numbers for the timestamp */
|
85
|
|
-+ nonce_time = strtoul (nonce + len - 8, (char **)NULL, 16);
|
86
|
|
-+ t = (uint32_t) MHD_monotonic_time();
|
87
|
|
-+ /*
|
88
|
|
-+ * First level vetting for the nonce validity: if the timestamp
|
89
|
|
-+ * attached to the nonce exceeds `nonce_timeout', then the nonce is
|
90
|
|
-+ * invalid.
|
91
|
|
-+ */
|
92
|
|
-+ if ( (t > nonce_time + nonce_timeout) ||
|
93
|
|
-+ (nonce_time + nonce_timeout < nonce_time) )
|
94
|
|
-+ {
|
95
|
|
-+ /* too old */
|
96
|
|
-+ return MHD_INVALID_NONCE;
|
97
|
|
-+ }
|
98
|
|
-+
|
99
|
|
-+ calculate_nonce (nonce_time,
|
100
|
|
-+ connection->method,
|
101
|
|
-+ connection->daemon->digest_auth_random,
|
102
|
|
-+ connection->daemon->digest_auth_rand_size,
|
103
|
|
-+ connection->url,
|
104
|
|
-+ realm,
|
105
|
|
-+ noncehashexp);
|
106
|
|
-+ /*
|
107
|
|
-+ * Second level vetting for the nonce validity
|
108
|
|
-+ * if the timestamp attached to the nonce is valid
|
109
|
|
-+ * and possibly fabricated (in case of an attack)
|
110
|
|
-+ * the attacker must also know the random seed to be
|
111
|
|
-+ * able to generate a "sane" nonce, which if he does
|
112
|
|
-+ * not, the nonce fabrication process going to be
|
113
|
|
-+ * very hard to achieve.
|
114
|
|
-+ */
|
115
|
|
-+
|
116
|
|
-+ if (0 != strcmp (nonce, noncehashexp))
|
117
|
|
-+ {
|
118
|
|
-+ return MHD_INVALID_NONCE;
|
119
|
|
-+ }
|
120
|
|
-+ if ( (0 == lookup_sub_value (cnonce,
|
121
|
|
-+ sizeof (cnonce),
|
122
|
|
-+ header, "cnonce")) ||
|
123
|
|
-+ (0 == lookup_sub_value (qop, sizeof (qop), header, "qop")) ||
|
124
|
|
-+ ( (0 != strcmp (qop, "auth")) &&
|
125
|
|
-+ (0 != strcmp (qop, "")) ) ||
|
126
|
|
-+ (0 == lookup_sub_value (nc, sizeof (nc), header, "nc")) ||
|
127
|
|
-+ (0 == lookup_sub_value (response, sizeof (response), header, "response")) )
|
128
|
|
-+ {
|
129
|
|
-+#if HAVE_MESSAGES
|
130
|
|
-+ MHD_DLOG (connection->daemon,
|
131
|
|
-+ "Authentication failed, invalid format.\n");
|
132
|
|
-+#endif
|
133
|
|
-+ return MHD_NO;
|
134
|
|
-+ }
|
135
|
|
-+ nci = strtoul (nc, &end, 16);
|
136
|
|
-+ if ( ('\0' != *end) ||
|
137
|
|
-+ ( (LONG_MAX == nci) &&
|
138
|
|
-+ (ERANGE == errno) ) )
|
139
|
|
-+ {
|
140
|
|
-+#if HAVE_MESSAGES
|
141
|
|
-+ MHD_DLOG (connection->daemon,
|
142
|
|
-+ "Authentication failed, invalid format.\n");
|
143
|
|
-+#endif
|
144
|
|
-+ return MHD_NO; /* invalid nonce format */
|
145
|
|
-+ }
|
146
|
|
-+ /*
|
147
|
|
-+ * Checking if that combination of nonce and nc is sound
|
148
|
|
-+ * and not a replay attack attempt. Also adds the nonce
|
149
|
|
-+ * to the nonce-nc map if it does not exist there.
|
150
|
|
-+ */
|
151
|
|
-+
|
152
|
|
-+ if (MHD_YES != check_nonce_nc (connection, nonce, nci))
|
153
|
|
-+ {
|
154
|
|
-+ return MHD_NO;
|
155
|
|
-+ }
|
156
|
|
-+
|
157
|
|
- {
|
158
|
|
- char *uri;
|
159
|
|
--
|
160
|
|
-- uri = malloc(left + 1);
|
161
|
|
-+
|
162
|
|
-+ uri = malloc (left + 1);
|
163
|
|
- if (NULL == uri)
|
164
|
|
- {
|
165
|
|
- #if HAVE_MESSAGES
|
166
|
|
-@@ -648,24 +730,31 @@ MHD_digest_auth_check (struct MHD_Connec
|
167
|
|
- left + 1,
|
168
|
|
- header, "uri"))
|
169
|
|
- {
|
170
|
|
-- free(uri);
|
171
|
|
-+ free (uri);
|
172
|
|
- return MHD_NO;
|
173
|
|
- }
|
174
|
|
-
|
175
|
|
-- /* 8 = 4 hexadecimal numbers for the timestamp */
|
176
|
|
-- nonce_time = strtoul (nonce + len - 8, (char **)NULL, 16);
|
177
|
|
-- t = (uint32_t) MHD_monotonic_time();
|
178
|
|
-- /*
|
179
|
|
-- * First level vetting for the nonce validity: if the timestamp
|
180
|
|
-- * attached to the nonce exceeds `nonce_timeout', then the nonce is
|
181
|
|
-- * invalid.
|
182
|
|
-- */
|
183
|
|
-- if ( (t > nonce_time + nonce_timeout) ||
|
184
|
|
-- (nonce_time + nonce_timeout < nonce_time) )
|
185
|
|
-- {
|
186
|
|
-- free(uri);
|
187
|
|
-- return MHD_INVALID_NONCE;
|
188
|
|
-- }
|
189
|
|
-+ digest_calc_ha1("md5",
|
190
|
|
-+ username,
|
191
|
|
-+ realm,
|
192
|
|
-+ password,
|
193
|
|
-+ nonce,
|
194
|
|
-+ cnonce,
|
195
|
|
-+ ha1);
|
196
|
|
-+ digest_calc_response (ha1,
|
197
|
|
-+ nonce,
|
198
|
|
-+ nc,
|
199
|
|
-+ cnonce,
|
200
|
|
-+ qop,
|
201
|
|
-+ connection->method,
|
202
|
|
-+ uri,
|
203
|
|
-+ hentity,
|
204
|
|
-+ respexp);
|
205
|
|
-+
|
206
|
|
-+ /* Need to unescape URI before comparing with connection->url */
|
207
|
|
-+ connection->daemon->unescape_callback (connection->daemon->unescape_callback_cls,
|
208
|
|
-+ connection,
|
209
|
|
-+ uri);
|
210
|
|
- if (0 != strncmp (uri,
|
211
|
|
- connection->url,
|
212
|
|
- strlen (connection->url)))
|
213
|
|
-@@ -674,9 +763,10 @@ MHD_digest_auth_check (struct MHD_Connec
|
214
|
|
- MHD_DLOG (connection->daemon,
|
215
|
|
- "Authentication failed, URI does not match.\n");
|
216
|
|
- #endif
|
217
|
|
-- free(uri);
|
218
|
|
-+ free (uri);
|
219
|
|
- return MHD_NO;
|
220
|
|
- }
|
221
|
|
-+
|
222
|
|
- {
|
223
|
|
- const char *args = strchr (uri, '?');
|
224
|
|
-
|
225
|
|
-@@ -692,89 +782,11 @@ MHD_digest_auth_check (struct MHD_Connec
|
226
|
|
- MHD_DLOG (connection->daemon,
|
227
|
|
- "Authentication failed, arguments do not match.\n");
|
228
|
|
- #endif
|
229
|
|
-- free(uri);
|
230
|
|
-+ free (uri);
|
231
|
|
- return MHD_NO;
|
232
|
|
- }
|
233
|
|
- }
|
234
|
|
-- calculate_nonce (nonce_time,
|
235
|
|
-- connection->method,
|
236
|
|
-- connection->daemon->digest_auth_random,
|
237
|
|
-- connection->daemon->digest_auth_rand_size,
|
238
|
|
-- connection->url,
|
239
|
|
-- realm,
|
240
|
|
-- noncehashexp);
|
241
|
|
-- /*
|
242
|
|
-- * Second level vetting for the nonce validity
|
243
|
|
-- * if the timestamp attached to the nonce is valid
|
244
|
|
-- * and possibly fabricated (in case of an attack)
|
245
|
|
-- * the attacker must also know the random seed to be
|
246
|
|
-- * able to generate a "sane" nonce, which if he does
|
247
|
|
-- * not, the nonce fabrication process going to be
|
248
|
|
-- * very hard to achieve.
|
249
|
|
-- */
|
250
|
|
--
|
251
|
|
-- if (0 != strcmp (nonce, noncehashexp))
|
252
|
|
-- {
|
253
|
|
-- free(uri);
|
254
|
|
-- return MHD_INVALID_NONCE;
|
255
|
|
-- }
|
256
|
|
-- if ( (0 == lookup_sub_value (cnonce,
|
257
|
|
-- sizeof (cnonce),
|
258
|
|
-- header, "cnonce")) ||
|
259
|
|
-- (0 == lookup_sub_value (qop, sizeof (qop), header, "qop")) ||
|
260
|
|
-- ( (0 != strcmp (qop, "auth")) &&
|
261
|
|
-- (0 != strcmp (qop, "")) ) ||
|
262
|
|
-- (0 == lookup_sub_value (nc, sizeof (nc), header, "nc")) ||
|
263
|
|
-- (0 == lookup_sub_value (response, sizeof (response), header, "response")) )
|
264
|
|
-- {
|
265
|
|
--#if HAVE_MESSAGES
|
266
|
|
-- MHD_DLOG (connection->daemon,
|
267
|
|
-- "Authentication failed, invalid format.\n");
|
268
|
|
--#endif
|
269
|
|
-- free(uri);
|
270
|
|
-- return MHD_NO;
|
271
|
|
-- }
|
272
|
|
-- nci = strtoul (nc, &end, 16);
|
273
|
|
-- if ( ('\0' != *end) ||
|
274
|
|
-- ( (LONG_MAX == nci) &&
|
275
|
|
-- (ERANGE == errno) ) )
|
276
|
|
-- {
|
277
|
|
--#if HAVE_MESSAGES
|
278
|
|
-- MHD_DLOG (connection->daemon,
|
279
|
|
-- "Authentication failed, invalid format.\n");
|
280
|
|
--#endif
|
281
|
|
-- free(uri);
|
282
|
|
-- return MHD_NO; /* invalid nonce format */
|
283
|
|
-- }
|
284
|
|
-- /*
|
285
|
|
-- * Checking if that combination of nonce and nc is sound
|
286
|
|
-- * and not a replay attack attempt. Also adds the nonce
|
287
|
|
-- * to the nonce-nc map if it does not exist there.
|
288
|
|
-- */
|
289
|
|
--
|
290
|
|
-- if (MHD_YES != check_nonce_nc (connection, nonce, nci))
|
291
|
|
-- {
|
292
|
|
-- free(uri);
|
293
|
|
-- return MHD_NO;
|
294
|
|
-- }
|
295
|
|
--
|
296
|
|
-- digest_calc_ha1("md5",
|
297
|
|
-- username,
|
298
|
|
-- realm,
|
299
|
|
-- password,
|
300
|
|
-- nonce,
|
301
|
|
-- cnonce,
|
302
|
|
-- ha1);
|
303
|
|
-- digest_calc_response (ha1,
|
304
|
|
-- nonce,
|
305
|
|
-- nc,
|
306
|
|
-- cnonce,
|
307
|
|
-- qop,
|
308
|
|
-- connection->method,
|
309
|
|
-- uri,
|
310
|
|
-- hentity,
|
311
|
|
-- respexp);
|
312
|
|
-- free(uri);
|
313
|
|
-+ free (uri);
|
314
|
|
- return (0 == strcmp(response, respexp))
|
315
|
|
- ? MHD_YES
|
316
|
|
- : MHD_NO;
|
317
|
|
-@@ -835,7 +847,7 @@ MHD_queue_auth_fail_response (struct MHD
|
318
|
|
- : "");
|
319
|
|
- {
|
320
|
|
- char *header;
|
321
|
|
--
|
322
|
|
-+
|
323
|
|
- header = malloc(hlen + 1);
|
324
|
|
- if (NULL == header)
|
325
|
|
- {
|
326
|
|
---- a/src/microhttpd/daemon.c
|
327
|
|
-+++ b/src/microhttpd/daemon.c
|
328
|
|
-@@ -73,7 +73,7 @@
|
329
|
|
- /**
|
330
|
|
- * Default connection limit.
|
331
|
|
- */
|
332
|
|
--#ifndef WINDOWS
|
333
|
|
-+#ifndef MHD_WINSOCK_SOCKETS
|
334
|
|
- #define MHD_MAX_CONNECTIONS_DEFAULT FD_SETSIZE - 4
|
335
|
|
- #else
|
336
|
|
- #define MHD_MAX_CONNECTIONS_DEFAULT FD_SETSIZE
|
337
|
|
-@@ -1271,7 +1271,7 @@ internal_add_connection (struct MHD_Daem
|
338
|
|
- return MHD_NO;
|
339
|
|
- }
|
340
|
|
-
|
341
|
|
--#ifndef WINDOWS
|
342
|
|
-+#ifndef MHD_WINSOCK_SOCKETS
|
343
|
|
- if ( (client_socket >= FD_SETSIZE) &&
|
344
|
|
- (0 == (daemon->options & (MHD_USE_POLL | MHD_USE_EPOLL_LINUX_ONLY))) )
|
345
|
|
- {
|
346
|
|
-@@ -1418,7 +1418,7 @@ internal_add_connection (struct MHD_Daem
|
347
|
|
- #endif
|
348
|
|
- {
|
349
|
|
- /* make socket non-blocking */
|
350
|
|
--#if !defined(WINDOWS) || defined(CYGWIN)
|
351
|
|
-+#if !defined(MHD_WINSOCK_SOCKETS)
|
352
|
|
- int flags = fcntl (connection->socket_fd, F_GETFL);
|
353
|
|
- if ( (-1 == flags) ||
|
354
|
|
- (0 != fcntl (connection->socket_fd, F_SETFL, flags | O_NONBLOCK)) )
|
355
|
|
-@@ -1797,7 +1797,7 @@ static void
|
356
|
|
- make_nonblocking_noninheritable (struct MHD_Daemon *daemon,
|
357
|
|
- MHD_socket sock)
|
358
|
|
- {
|
359
|
|
--#ifdef WINDOWS
|
360
|
|
-+#ifdef MHD_WINSOCK_SOCKETS
|
361
|
|
- DWORD dwFlags;
|
362
|
|
- unsigned long flags = 1;
|
363
|
|
-
|
364
|
|
-@@ -3611,7 +3611,7 @@ MHD_start_daemon_va (unsigned int flags,
|
365
|
|
- daemon->socket_fd = MHD_INVALID_SOCKET;
|
366
|
|
- daemon->listening_address_reuse = 0;
|
367
|
|
- daemon->options = flags;
|
368
|
|
--#if WINDOWS
|
369
|
|
-+#if defined(MHD_WINSOCK_SOCKETS) || defined(CYGWIN)
|
370
|
|
- /* Winsock is broken with respect to 'shutdown';
|
371
|
|
- this disables us calling 'shutdown' on W32. */
|
372
|
|
- daemon->options |= MHD_USE_EPOLL_TURBO;
|
373
|
|
-@@ -3650,7 +3650,7 @@ MHD_start_daemon_va (unsigned int flags,
|
374
|
|
- free (daemon);
|
375
|
|
- return NULL;
|
376
|
|
- }
|
377
|
|
--#ifndef WINDOWS
|
378
|
|
-+#ifndef MHD_WINSOCK_SOCKETS
|
379
|
|
- if ( (0 == (flags & (MHD_USE_POLL | MHD_USE_EPOLL_LINUX_ONLY))) &&
|
380
|
|
- (1 == use_pipe) &&
|
381
|
|
- (daemon->wpipe[0] >= FD_SETSIZE) )
|
382
|
|
-@@ -3934,7 +3934,7 @@ MHD_start_daemon_va (unsigned int flags,
|
383
|
|
- (http://msdn.microsoft.com/en-us/library/ms738574%28v=VS.85%29.aspx);
|
384
|
|
- and may also be missing on older POSIX systems; good luck if you have any of those,
|
385
|
|
- your IPv6 socket may then also bind against IPv4 anyway... */
|
386
|
|
--#ifndef WINDOWS
|
387
|
|
-+#ifndef MHD_WINSOCK_SOCKETS
|
388
|
|
- const int
|
389
|
|
- #else
|
390
|
|
- const char
|
391
|
|
-@@ -4016,7 +4016,7 @@ MHD_start_daemon_va (unsigned int flags,
|
392
|
|
- {
|
393
|
|
- socket_fd = daemon->socket_fd;
|
394
|
|
- }
|
395
|
|
--#ifndef WINDOWS
|
396
|
|
-+#ifndef MHD_WINSOCK_SOCKETS
|
397
|
|
- if ( (socket_fd >= FD_SETSIZE) &&
|
398
|
|
- (0 == (flags & (MHD_USE_POLL | MHD_USE_EPOLL_LINUX_ONLY)) ) )
|
399
|
|
- {
|
400
|
|
-@@ -4121,7 +4121,7 @@ MHD_start_daemon_va (unsigned int flags,
|
401
|
|
- if ( (daemon->worker_pool_size > 0) &&
|
402
|
|
- (0 == (daemon->options & MHD_USE_NO_LISTEN_SOCKET)) )
|
403
|
|
- {
|
404
|
|
--#if !defined(WINDOWS) || defined(CYGWIN)
|
405
|
|
-+#if !defined(MHD_WINSOCK_SOCKETS)
|
406
|
|
- int sk_flags;
|
407
|
|
- #else
|
408
|
|
- unsigned long sk_flags;
|
409
|
|
-@@ -4140,7 +4140,7 @@ MHD_start_daemon_va (unsigned int flags,
|
410
|
|
- /* Accept must be non-blocking. Multiple children may wake up
|
411
|
|
- * to handle a new connection, but only one will win the race.
|
412
|
|
- * The others must immediately return. */
|
413
|
|
--#if !defined(WINDOWS) || defined(CYGWIN)
|
414
|
|
-+#if !defined(MHD_WINSOCK_SOCKETS)
|
415
|
|
- sk_flags = fcntl (socket_fd, F_GETFL);
|
416
|
|
- if (sk_flags < 0)
|
417
|
|
- goto thread_failed;
|
418
|
|
-@@ -4150,7 +4150,7 @@ MHD_start_daemon_va (unsigned int flags,
|
419
|
|
- sk_flags = 1;
|
420
|
|
- if (SOCKET_ERROR == ioctlsocket (socket_fd, FIONBIO, &sk_flags))
|
421
|
|
- goto thread_failed;
|
422
|
|
--#endif /* WINDOWS && !CYGWIN */
|
423
|
|
-+#endif /* MHD_WINSOCK_SOCKETS */
|
424
|
|
-
|
425
|
|
- /* Allocate memory for pooled objects */
|
426
|
|
- daemon->worker_pool = malloc (sizeof (struct MHD_Daemon)
|
427
|
|
-@@ -4182,7 +4182,7 @@ MHD_start_daemon_va (unsigned int flags,
|
428
|
|
- #endif
|
429
|
|
- goto thread_failed;
|
430
|
|
- }
|
431
|
|
--#ifndef WINDOWS
|
432
|
|
-+#ifndef MHD_WINSOCK_SOCKETS
|
433
|
|
- if ( (0 == (flags & (MHD_USE_POLL | MHD_USE_EPOLL_LINUX_ONLY))) &&
|
434
|
|
- (MHD_USE_SUSPEND_RESUME == (flags & MHD_USE_SUSPEND_RESUME)) &&
|
435
|
|
- (d->wpipe[0] >= FD_SETSIZE) )
|
436
|
|
-@@ -4343,7 +4343,7 @@ close_all_connections (struct MHD_Daemon
|
437
|
|
- {
|
438
|
|
- shutdown (pos->socket_fd,
|
439
|
|
- (pos->read_closed == MHD_YES) ? SHUT_WR : SHUT_RDWR);
|
440
|
|
--#if WINDOWS
|
441
|
|
-+#if MHD_WINSOCK_SOCKETS
|
442
|
|
- if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
|
443
|
|
- (MHD_INVALID_PIPE_ != daemon->wpipe[1]) &&
|
444
|
|
- (1 != MHD_pipe_write_ (daemon->wpipe[1], "e", 1)) )
|
445
|
|
---- a/src/include/microhttpd.h
|
446
|
|
-+++ b/src/include/microhttpd.h
|
447
|
|
-@@ -130,7 +130,7 @@ typedef intptr_t ssize_t;
|
448
|
|
- * Current version of the library.
|
449
|
|
- * 0x01093001 = 1.9.30-1.
|
450
|
|
- */
|
451
|
|
--#define MHD_VERSION 0x00094200
|
452
|
|
-+#define MHD_VERSION 0x00094202
|
453
|
|
-
|
454
|
|
- /**
|
455
|
|
- * MHD-internal return code for "YES".
|
456
|
|
-@@ -194,6 +194,53 @@ typedef SOCKET MHD_socket;
|
457
|
|
- #endif /* MHD_SOCKET_DEFINED */
|
458
|
|
-
|
459
|
|
- /**
|
460
|
|
-+ * Define MHD_NO_DEPRECATION before including "microhttpd.h" to disable deprecation messages
|
461
|
|
-+ */
|
462
|
|
-+#ifdef MHD_NO_DEPRECATION
|
463
|
|
-+#define _MHD_DEPR_MACRO(msg)
|
464
|
|
-+#define _MHD_DEPR_FUNC(msg)
|
465
|
|
-+#endif /* MHD_NO_DEPRECATION */
|
466
|
|
-+
|
467
|
|
-+#ifndef _MHD_DEPR_MACRO
|
468
|
|
-+#if defined(_MSC_FULL_VER) && _MSC_VER+0 >= 1500
|
469
|
|
-+/* Stringify macros */
|
470
|
|
-+#define _MHD_INSTRMACRO(a) #a
|
471
|
|
-+#define _MHD_STRMACRO(a) _MHD_INSTRMACRO(a)
|
472
|
|
-+#define _MHD_DEPR_MACRO(msg) __pragma(message(__FILE__ "(" _MHD_STRMACRO(__LINE__)"): warning: " msg))
|
473
|
|
-+#elif defined(__clang__) || defined (__GNUC_PATCHLEVEL__)
|
474
|
|
-+#define _MHD_GCC_PRAG(x) _Pragma (#x)
|
475
|
|
-+#if __clang_major__+0 >= 5 || \
|
476
|
|
-+ (!defined(__apple_build_version__) && (__clang_major__+0 > 3 || (__clang_major__+0 == 3 && __clang_minor__ >= 3))) || \
|
477
|
|
-+ __GNUC__+0 > 4 || (__GNUC__+0 == 4 && __GNUC_MINOR__+0 >= 8)
|
478
|
|
-+#define _MHD_DEPR_MACRO(msg) _MHD_GCC_PRAG(GCC warning msg)
|
479
|
|
-+#else /* older clang or GCC */
|
480
|
|
-+#define _MHD_DEPR_MACRO(msg) _MHD_GCC_PRAG(message msg)
|
481
|
|
-+#endif
|
482
|
|
-+/* #elif defined(SOMEMACRO) */ /* add compiler-specific macros here if required */
|
483
|
|
-+#else /* other compilers */
|
484
|
|
-+#define _MHD_DEPR_MACRO(msg)
|
485
|
|
-+#endif
|
486
|
|
-+#endif /* _MHD_DEPR_MACRO */
|
487
|
|
-+
|
488
|
|
-+#ifndef _MHD_DEPR_FUNC
|
489
|
|
-+#if defined(_MSC_FULL_VER) && _MSC_VER+0 >= 1400
|
490
|
|
-+#define _MHD_DEPR_FUNC(msg) __declspec(deprecated(msg))
|
491
|
|
-+#elif defined(_MSC_FULL_VER) && _MSC_VER+0 >= 1310
|
492
|
|
-+/* VS .NET 2003 deprecation do not support custom messages */
|
493
|
|
-+#define _MHD_DEPR_FUNC(msg) __declspec(deprecated)
|
494
|
|
-+#elif defined (__clang__) && \
|
495
|
|
-+ (__clang_major__+0 >= 4 || (!defined(__apple_build_version__) && __clang_major__+0 >= 3))
|
496
|
|
-+#define _MHD_DEPR_FUNC(msg) __attribute__((deprecated(msg)))
|
497
|
|
-+#elif defined (__clang__) || __GNUC__+0 > 3 || (__GNUC__+0 == 3 && __GNUC_MINOR__+0 >= 1)
|
498
|
|
-+/* GCC-style deprecation do not support custom messages */
|
499
|
|
-+#define _MHD_DEPR_FUNC(msg) __attribute__((__deprecated__))
|
500
|
|
-+/* #elif defined(SOMEMACRO) */ /* add compiler-specific macros here if required */
|
501
|
|
-+#else /* other compilers */
|
502
|
|
-+#define _MHD_DEPR_FUNC(msg)
|
503
|
|
-+#endif
|
504
|
|
-+#endif /* _MHD_DEPR_FUNC */
|
505
|
|
-+
|
506
|
|
-+/**
|
507
|
|
- * Not all architectures and `printf()`'s support the `long long` type.
|
508
|
|
- * This gives the ability to replace `long long` with just a `long`,
|
509
|
|
- * standard `int` or a `short`.
|
510
|
|
-@@ -204,6 +251,8 @@ typedef SOCKET MHD_socket;
|
511
|
|
- */
|
512
|
|
- #define MHD_LONG_LONG long long
|
513
|
|
- #define MHD_UNSIGNED_LONG_LONG unsigned long long
|
514
|
|
-+#else /* MHD_LONG_LONG */
|
515
|
|
-+_MHD_DEPR_MACRO("Macro MHD_LONG_LONG is deprecated, use MHD_UNSIGNED_LONG_LONG")
|
516
|
|
- #endif
|
517
|
|
- /**
|
518
|
|
- * Format string for printing a variable of type #MHD_LONG_LONG.
|
519
|
|
-@@ -215,6 +264,8 @@ typedef SOCKET MHD_socket;
|
520
|
|
- */
|
521
|
|
- #define MHD_LONG_LONG_PRINTF "ll"
|
522
|
|
- #define MHD_UNSIGNED_LONG_LONG_PRINTF "%llu"
|
523
|
|
-+#else /* MHD_LONG_LONG_PRINTF */
|
524
|
|
-+_MHD_DEPR_MACRO("Macro MHD_LONG_LONG_PRINTF is deprecated, use MHD_UNSIGNED_LONG_LONG_PRINTF")
|
525
|
|
- #endif
|
526
|
|
-
|
527
|
|
-
|
528
|
|
-@@ -253,7 +304,8 @@ typedef SOCKET MHD_socket;
|
529
|
|
- #define MHD_HTTP_METHOD_NOT_ALLOWED 405
|
530
|
|
- #define MHD_HTTP_NOT_ACCEPTABLE 406
|
531
|
|
- /** @deprecated */
|
532
|
|
--#define MHD_HTTP_METHOD_NOT_ACCEPTABLE 406
|
533
|
|
-+#define MHD_HTTP_METHOD_NOT_ACCEPTABLE \
|
534
|
|
-+ _MHD_DEPR_MACRO("Value MHD_HTTP_METHOD_NOT_ACCEPTABLE is deprecated, use MHD_HTTP_NOT_ACCEPTABLE") 406
|
535
|
|
- #define MHD_HTTP_PROXY_AUTHENTICATION_REQUIRED 407
|
536
|
|
- #define MHD_HTTP_REQUEST_TIMEOUT 408
|
537
|
|
- #define MHD_HTTP_CONFLICT 409
|
538
|
|
-@@ -1953,6 +2005,7 @@ MHD_create_response_from_callback (uint6
|
539
|
|
- * @deprecated use #MHD_create_response_from_buffer instead
|
540
|
|
- * @ingroup response
|
541
|
|
- */
|
542
|
|
-+_MHD_DEPR_FUNC("MHD_create_response_from_data() is deprecated, use MHD_create_response_from_buffer()") \
|
543
|
|
- _MHD_EXTERN struct MHD_Response *
|
544
|
|
- MHD_create_response_from_data (size_t size,
|
545
|
|
- void *data,
|
546
|
|
-@@ -2023,6 +2076,8 @@ MHD_create_response_from_buffer (size_t
|
547
|
|
- * @return NULL on error (i.e. invalid arguments, out of memory)
|
548
|
|
- * @ingroup response
|
549
|
|
- */
|
550
|
|
-+/* NOTE: this should be 'uint64_t' instead of 'size_t', but changing
|
551
|
|
-+ this would break API compatibility. */
|
552
|
|
- _MHD_EXTERN struct MHD_Response *
|
553
|
|
- MHD_create_response_from_fd (size_t size,
|
554
|
|
- int fd);
|
555
|
|
-@@ -2044,6 +2099,8 @@ MHD_create_response_from_fd (size_t size
|
556
|
|
- * @return NULL on error (i.e. invalid arguments, out of memory)
|
557
|
|
- * @ingroup response
|
558
|
|
- */
|
559
|
|
-+/* NOTE: this should be 'uint64_t' instead of 'size_t', but changing
|
560
|
|
-+ this would break API compatibility. */
|
561
|
|
- _MHD_EXTERN struct MHD_Response *
|
562
|
|
- MHD_create_response_from_fd_at_offset (size_t size,
|
563
|
|
- int fd,
|
564
|
|
---- a/src/include/platform_interface.h
|
565
|
|
-+++ b/src/include/platform_interface.h
|
566
|
|
-@@ -82,14 +82,14 @@
|
567
|
|
-
|
568
|
|
-
|
569
|
|
- /* MHD_socket_close_(fd) close any FDs (non-W32) / close only socket FDs (W32) */
|
570
|
|
--#if !defined(_WIN32) || defined(__CYGWIN__)
|
571
|
|
-+#if !defined(MHD_WINSOCK_SOCKETS)
|
572
|
|
- #define MHD_socket_close_(fd) close((fd))
|
573
|
|
- #else
|
574
|
|
- #define MHD_socket_close_(fd) closesocket((fd))
|
575
|
|
- #endif
|
576
|
|
-
|
577
|
|
- /* MHD_socket_errno_ is errno of last function (non-W32) / errno of last socket function (W32) */
|
578
|
|
--#if !defined(_WIN32) || defined(__CYGWIN__)
|
579
|
|
-+#if !defined(MHD_WINSOCK_SOCKETS)
|
580
|
|
- #define MHD_socket_errno_ errno
|
581
|
|
- #else
|
582
|
|
- #define MHD_socket_errno_ MHD_W32_errno_from_winsock_()
|
583
|
|
-@@ -97,21 +97,21 @@
|
584
|
|
-
|
585
|
|
- /* MHD_socket_last_strerr_ is description string of last errno (non-W32) /
|
586
|
|
- * description string of last socket error (W32) */
|
587
|
|
--#if !defined(_WIN32) || defined(__CYGWIN__)
|
588
|
|
-+#if !defined(MHD_WINSOCK_SOCKETS)
|
589
|
|
- #define MHD_socket_last_strerr_() strerror(errno)
|
590
|
|
- #else
|
591
|
|
- #define MHD_socket_last_strerr_() MHD_W32_strerror_last_winsock_()
|
592
|
|
- #endif
|
593
|
|
-
|
594
|
|
- /* MHD_strerror_ is strerror (both non-W32/W32) */
|
595
|
|
--#if !defined(_WIN32) || defined(__CYGWIN__)
|
596
|
|
-+#if !defined(MHD_WINSOCK_SOCKETS)
|
597
|
|
- #define MHD_strerror_(errnum) strerror((errnum))
|
598
|
|
- #else
|
599
|
|
- #define MHD_strerror_(errnum) MHD_W32_strerror_((errnum))
|
600
|
|
- #endif
|
601
|
|
-
|
602
|
|
- /* MHD_set_socket_errno_ set errno to errnum (non-W32) / set socket last error to errnum (W32) */
|
603
|
|
--#if !defined(_WIN32) || defined(__CYGWIN__)
|
604
|
|
-+#if !defined(MHD_WINSOCK_SOCKETS)
|
605
|
|
- #define MHD_set_socket_errno_(errnum) errno=(errnum)
|
606
|
|
- #else
|
607
|
|
- #define MHD_set_socket_errno_(errnum) MHD_W32_set_last_winsock_error_((errnum))
|
608
|
|
---- a/src/testcurl/test_digestauth.c
|
609
|
|
-+++ b/src/testcurl/test_digestauth.c
|
610
|
|
-@@ -73,7 +73,8 @@ ahc_echo (void *cls,
|
611
|
|
- const char *url,
|
612
|
|
- const char *method,
|
613
|
|
- const char *version,
|
614
|
|
-- const char *upload_data, size_t *upload_data_size,
|
615
|
|
-+ const char *upload_data,
|
616
|
|
-+ size_t *upload_data_size,
|
617
|
|
- void **unused)
|
618
|
|
- {
|
619
|
|
- struct MHD_Response *response;
|
620
|
|
-@@ -82,44 +83,47 @@ ahc_echo (void *cls,
|
621
|
|
- const char *realm = "test@example.com";
|
622
|
|
- int ret;
|
623
|
|
-
|
624
|
|
-- username = MHD_digest_auth_get_username(connection);
|
625
|
|
-+ username = MHD_digest_auth_get_username (connection);
|
626
|
|
- if ( (username == NULL) ||
|
627
|
|
- (0 != strcmp (username, "testuser")) )
|
628
|
|
- {
|
629
|
|
-- response = MHD_create_response_from_buffer(strlen (DENIED),
|
630
|
|
-- DENIED,
|
631
|
|
-- MHD_RESPMEM_PERSISTENT);
|
632
|
|
-+ response = MHD_create_response_from_buffer (strlen (DENIED),
|
633
|
|
-+ DENIED,
|
634
|
|
-+ MHD_RESPMEM_PERSISTENT);
|
635
|
|
- ret = MHD_queue_auth_fail_response(connection, realm,
|
636
|
|
- MY_OPAQUE,
|
637
|
|
- response,
|
638
|
|
-- MHD_NO);
|
639
|
|
-- MHD_destroy_response(response);
|
640
|
|
-+ MHD_NO);
|
641
|
|
-+ MHD_destroy_response(response);
|
642
|
|
- return ret;
|
643
|
|
- }
|
644
|
|
- ret = MHD_digest_auth_check(connection, realm,
|
645
|
|
-- username,
|
646
|
|
-- password,
|
647
|
|
-+ username,
|
648
|
|
-+ password,
|
649
|
|
- 300);
|
650
|
|
- free(username);
|
651
|
|
- if ( (ret == MHD_INVALID_NONCE) ||
|
652
|
|
- (ret == MHD_NO) )
|
653
|
|
- {
|
654
|
|
-- response = MHD_create_response_from_buffer(strlen (DENIED),
|
655
|
|
-+ response = MHD_create_response_from_buffer(strlen (DENIED),
|
656
|
|
- DENIED,
|
657
|
|
-- MHD_RESPMEM_PERSISTENT);
|
658
|
|
-- if (NULL == response)
|
659
|
|
-+ MHD_RESPMEM_PERSISTENT);
|
660
|
|
-+ if (NULL == response)
|
661
|
|
- return MHD_NO;
|
662
|
|
- ret = MHD_queue_auth_fail_response(connection, realm,
|
663
|
|
- MY_OPAQUE,
|
664
|
|
- response,
|
665
|
|
-- (ret == MHD_INVALID_NONCE) ? MHD_YES : MHD_NO);
|
666
|
|
-- MHD_destroy_response(response);
|
667
|
|
-+ (ret == MHD_INVALID_NONCE) ? MHD_YES : MHD_NO);
|
668
|
|
-+ MHD_destroy_response(response);
|
669
|
|
- return ret;
|
670
|
|
- }
|
671
|
|
-- response = MHD_create_response_from_buffer(strlen(PAGE), PAGE,
|
672
|
|
-- MHD_RESPMEM_PERSISTENT);
|
673
|
|
-- ret = MHD_queue_response(connection, MHD_HTTP_OK, response);
|
674
|
|
-- MHD_destroy_response(response);
|
675
|
|
-+ response = MHD_create_response_from_buffer (strlen(PAGE),
|
676
|
|
-+ PAGE,
|
677
|
|
-+ MHD_RESPMEM_PERSISTENT);
|
678
|
|
-+ ret = MHD_queue_response (connection,
|
679
|
|
-+ MHD_HTTP_OK,
|
680
|
|
-+ response);
|
681
|
|
-+ MHD_destroy_response (response);
|
682
|
|
- return ret;
|
683
|
|
- }
|
684
|
|
-
|
685
|
|
-@@ -144,24 +148,24 @@ testDigestAuth ()
|
686
|
|
- fd = open("/dev/urandom", O_RDONLY);
|
687
|
|
- if (-1 == fd)
|
688
|
|
- {
|
689
|
|
-- fprintf(stderr, "Failed to open `%s': %s\n",
|
690
|
|
-- "/dev/urandom",
|
691
|
|
-- strerror(errno));
|
692
|
|
-- return 1;
|
693
|
|
-- }
|
694
|
|
-+ fprintf(stderr, "Failed to open `%s': %s\n",
|
695
|
|
-+ "/dev/urandom",
|
696
|
|
-+ strerror(errno));
|
697
|
|
-+ return 1;
|
698
|
|
-+ }
|
699
|
|
- while (off < 8)
|
700
|
|
-- {
|
701
|
|
-- len = read(fd, rnd, 8);
|
702
|
|
-- if (len == -1)
|
703
|
|
-- {
|
704
|
|
-- fprintf(stderr, "Failed to read `%s': %s\n",
|
705
|
|
-- "/dev/urandom",
|
706
|
|
-- strerror(errno));
|
707
|
|
-- (void) close(fd);
|
708
|
|
-- return 1;
|
709
|
|
-- }
|
710
|
|
-- off += len;
|
711
|
|
-- }
|
712
|
|
-+ {
|
713
|
|
-+ len = read(fd, rnd, 8);
|
714
|
|
-+ if (len == -1)
|
715
|
|
-+ {
|
716
|
|
-+ fprintf(stderr, "Failed to read `%s': %s\n",
|
717
|
|
-+ "/dev/urandom",
|
718
|
|
-+ strerror(errno));
|
719
|
|
-+ (void) close(fd);
|
720
|
|
-+ return 1;
|
721
|
|
-+ }
|
722
|
|
-+ off += len;
|
723
|
|
-+ }
|
724
|
|
- (void) close(fd);
|
725
|
|
- #else
|
726
|
|
- {
|
727
|
|
-@@ -193,7 +197,7 @@ testDigestAuth ()
|
728
|
|
- if (d == NULL)
|
729
|
|
- return 1;
|
730
|
|
- c = curl_easy_init ();
|
731
|
|
-- curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:1337/");
|
732
|
|
-+ curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:1337/bar%20 foo?a=bü%20");
|
733
|
|
- curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer);
|
734
|
|
- curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
|
735
|
|
- curl_easy_setopt (c, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
|
736
|
|
-@@ -225,7 +229,6 @@ testDigestAuth ()
|
737
|
|
- }
|
738
|
|
-
|
739
|
|
-
|
740
|
|
--
|
741
|
|
- int
|
742
|
|
- main (int argc, char *const *argv)
|
743
|
|
- {
|
744
|
|
---- a/src/testcurl/https/test_https_time_out.c
|
745
|
|
-+++ b/src/testcurl/https/test_https_time_out.c
|
746
|
|
-@@ -64,7 +64,7 @@ test_tls_session_time_out (gnutls_sessio
|
747
|
|
-
|
748
|
|
- gnutls_transport_set_ptr (session, (gnutls_transport_ptr_t) (intptr_t) sd);
|
749
|
|
-
|
750
|
|
-- ret = connect (sd, &sa, sizeof (struct sockaddr_in));
|
751
|
|
-+ ret = connect (sd, (struct sockaddr *) &sa, sizeof (struct sockaddr_in));
|
752
|
|
-
|
753
|
|
- if (ret < 0)
|
754
|
|
- {
|