comparison Resources/Patches/civetweb-1.11.patch @ 3146:d5d11e43d0fb

fix memory leak in civetweb
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 17 Jan 2019 21:30:52 +0100
parents 972cc98959a3
children b7c52549595e
comparison
equal deleted inserted replaced
3145:239331e4ee0b 3146:d5d11e43d0fb
1 Only in civetweb-1.11/src: a.out
1 diff -urEb civetweb-1.11.orig/src/civetweb.c civetweb-1.11/src/civetweb.c 2 diff -urEb civetweb-1.11.orig/src/civetweb.c civetweb-1.11/src/civetweb.c
2 --- civetweb-1.11.orig/src/civetweb.c 2019-01-16 10:52:21.313348500 +0100 3 --- civetweb-1.11.orig/src/civetweb.c 2019-01-17 21:09:41.852888857 +0100
3 +++ civetweb-1.11/src/civetweb.c 2019-01-16 11:59:58.995605655 +0100 4 +++ civetweb-1.11/src/civetweb.c 2019-01-17 21:23:54.273424124 +0100
4 @@ -20,6 +20,14 @@ 5 @@ -59,6 +59,9 @@
5 * THE SOFTWARE. 6 #if defined(__linux__) && !defined(_XOPEN_SOURCE)
6 */ 7 #define _XOPEN_SOURCE 600 /* For flockfile() on Linux */
8 #endif
9 +#if defined(__LSB_VERSION__)
10 +#define NEED_TIMEGM
11 +#endif
12 #if !defined(_LARGEFILE_SOURCE)
13 #define _LARGEFILE_SOURCE /* For fseeko(), ftello() */
14 #endif
15 @@ -129,6 +132,12 @@
7 16
17
18 /* Alternative queue is well tested and should be the new default */
19 +#if defined(__LSB_VERSION__)
20 +/* Function "eventfd()" is not available in Linux Standard Base, can't
21 + * use the alternative queue */
22 +#define NO_ALTERNATIVE_QUEUE
23 +#endif
8 + 24 +
9 +#if defined(__LSB_VERSION__) 25 #if defined(NO_ALTERNATIVE_QUEUE)
10 +// These definitions are mandatory for Linux Standard Base 26 #if defined(ALTERNATIVE_QUEUE)
11 +# define NO_CACHING 27 #error "Define ALTERNATIVE_QUEUE or NO_ALTERNATIVE_QUEUE or none, but not both"
12 +# define NO_ALTERNATIVE_QUEUE 28 @@ -536,6 +545,10 @@
13 +# define NO_THREAD_NAME
14 +#endif
15 +
16 #if defined(__GNUC__) || defined(__MINGW32__)
17 #define GCC_VERSION \
18 (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
19 @@ -536,6 +544,10 @@
20 #if !defined(EWOULDBLOCK) 29 #if !defined(EWOULDBLOCK)
21 #define EWOULDBLOCK WSAEWOULDBLOCK 30 #define EWOULDBLOCK WSAEWOULDBLOCK
22 #endif /* !EWOULDBLOCK */ 31 #endif /* !EWOULDBLOCK */
23 +#if !defined(ECONNRESET) 32 +#if !defined(ECONNRESET)
24 +// Macro ECONNRESET is not always defined (e.g. on Visual Studio 2008) 33 +/* This macro is not defined e.g. in Visual Studio 2008 */
25 +# define ECONNRESET WSAECONNRESET 34 +#define ECONNRESET WSAECONNRESET
26 +#endif /* !ECONNRESET */ 35 +#endif /* !ECONNRESET */
27 #define _POSIX_ 36 #define _POSIX_
28 #define INT64_FMT "I64d" 37 #define INT64_FMT "I64d"
29 #define UINT64_FMT "I64u" 38 #define UINT64_FMT "I64u"
39 @@ -2939,6 +2952,13 @@
40 #endif
41
42
43 +#if defined(__LSB_VERSION__)
44 +static void
45 +mg_set_thread_name(const char *threadName)
46 +{
47 + /* prctl() does not seem to be available in Linux Standard Base */
48 +}
49 +#else
50 static void
51 mg_set_thread_name(const char *name)
52 {
53 @@ -2980,6 +3000,7 @@
54 (void)prctl(PR_SET_NAME, threadName, 0, 0, 0);
55 #endif
56 }
57 +#endif
58 #else /* !defined(NO_THREAD_NAME) */
59 void
60 mg_set_thread_name(const char *threadName)
61 @@ -16919,6 +16940,10 @@
62 /* Message is a valid request */
63
64 /* Is there a "host" ? */
65 + /* https://github.com/civetweb/civetweb/pull/675/commits/96e3e8c50acb4b8e0c946d02b5f880a3e62986e1 */
66 + if (conn->host!=NULL) {
67 + mg_free((void *)conn->host);
68 + }
69 conn->host = alloc_get_host(conn);
70 if (!conn->host) {
71 mg_snprintf(conn,