Hello community, here is the log from the commit of package libmicrohttpd for openSUSE:Factory checked in at 2015-11-04 15:32:40 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/libmicrohttpd (Old) and /work/SRC/openSUSE:Factory/.libmicrohttpd.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "libmicrohttpd" Changes: -------- --- /work/SRC/openSUSE:Factory/libmicrohttpd/libmicrohttpd.changes 2015-10-14 16:41:11.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.libmicrohttpd.new/libmicrohttpd.changes 2015-11-04 15:32:42.000000000 +0100 @@ -1,0 +2,19 @@ +Sun Nov 1 11:44:58 UTC 2015 - mpluskal@suse.com + +- Update to 0.9.45 + * Rework deprecation maros: fix errors with old GCC versions, + improved support for old clang and new GCC. -EG + * Return correct header kind in MHD_get_connection_values() + even if a bitmask is used for the "kind" argument. -FC/CG + * Fixing transient resource leak affecting long-lived + connections with many keep-alives and HTTP request + pipelining under certain circumstances (which reduced + the receive window). + * Fixed assertion failure triggered by a race in + thread-per-connection mode on shutdown in rare + circumstances. -CG + * Deduplicate code between digestauth and connection + parsing logic for URI arguments, shared code moved + to new MHD_parse_arguments_ function in internal.c. -CG + +------------------------------------------------------------------- Old: ---- libmicrohttpd-0.9.44.tar.gz libmicrohttpd-0.9.44.tar.gz.sig New: ---- libmicrohttpd-0.9.45.tar.gz libmicrohttpd-0.9.45.tar.gz.sig ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ libmicrohttpd.spec ++++++ --- /var/tmp/diff_new_pack.08IE75/_old 2015-11-04 15:32:43.000000000 +0100 +++ /var/tmp/diff_new_pack.08IE75/_new 2015-11-04 15:32:43.000000000 +0100 @@ -23,10 +23,10 @@ %define enable_libmicrospdy 0 %endif -%global libmicrohttpd libmicrohttpd10 +%global libmicrohttpd libmicrohttpd11 %global libmicrospdy libmicrospdy0 Name: libmicrohttpd -Version: 0.9.44 +Version: 0.9.45 Release: 0 Summary: Small Embeddable HTTP Server Library License: LGPL-2.1+ ++++++ libmicrohttpd-0.9.44.tar.gz -> libmicrohttpd-0.9.45.tar.gz ++++++ ++++ 2181 lines of diff (skipped) ++++ retrying with extended exclude list diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/libmicrohttpd-0.9.44/ChangeLog new/libmicrohttpd-0.9.45/ChangeLog --- old/libmicrohttpd-0.9.44/ChangeLog 2015-10-01 21:22:26.000000000 +0200 +++ new/libmicrohttpd-0.9.45/ChangeLog 2015-10-31 15:53:10.000000000 +0100 @@ -1,3 +1,28 @@ +Sat Oct 31 15:52:52 CET 2015 + Releasing libmicrohttpd 0.9.45. -CG + +Tue Oct 27 12:08:02 CET 2015 + Rework deprecation maros: fix errors with old GCC versions, + improved support for old clang and new GCC. -EG + +Sun Oct 25 23:05:32 CET 2015 + Return correct header kind in MHD_get_connection_values() + even if a bitmask is used for the "kind" argument. -FC/CG + +Sun Oct 25 15:29:23 CET 2015 + Fixing transient resource leak affecting long-lived + connections with many keep-alives and HTTP request + pipelining under certain circumstances (which reduced + the receive window). + Fixed assertion failure triggered by a race in + thread-per-connection mode on shutdown in rare + circumstances. -CG + +Mon Oct 5 11:53:52 CEST 2015 + Deduplicate code between digestauth and connection + parsing logic for URI arguments, shared code moved + to new MHD_parse_arguments_ function in internal.c. -CG + Thu Oct 1 21:22:05 CEST 2015 Releasing libmicrohttpd 0.9.44. -CG diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/libmicrohttpd-0.9.44/configure.ac new/libmicrohttpd-0.9.45/configure.ac --- old/libmicrohttpd-0.9.44/configure.ac 2015-10-01 21:21:49.000000000 +0200 +++ new/libmicrohttpd-0.9.45/configure.ac 2015-10-31 15:52:35.000000000 +0100 @@ -22,13 +22,13 @@ # AC_PREREQ([2.60]) LT_PREREQ([2.4.0]) -AC_INIT([libmicrohttpd],[0.9.44],[libmicrohttpd@gnu.org]) +AC_INIT([libmicrohttpd],[0.9.45],[libmicrohttpd@gnu.org]) AM_INIT_AUTOMAKE([silent-rules] [subdir-objects]) AC_CONFIG_HEADERS([MHD_config.h]) AC_CONFIG_MACRO_DIR([m4]) AH_TOP([#define _GNU_SOURCE 1]) -LIB_VERSION_CURRENT=44 +LIB_VERSION_CURRENT=45 LIB_VERSION_REVISION=0 LIB_VERSION_AGE=34 AC_SUBST(LIB_VERSION_CURRENT) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/libmicrohttpd-0.9.44/doc/libmicrohttpd.info new/libmicrohttpd-0.9.45/doc/libmicrohttpd.info --- old/libmicrohttpd-0.9.44/doc/libmicrohttpd.info 2015-10-01 21:23:00.000000000 +0200 +++ new/libmicrohttpd-0.9.45/doc/libmicrohttpd.info 2015-10-31 15:53:49.000000000 +0100 @@ -1,8 +1,8 @@ This is libmicrohttpd.info, produced by makeinfo version 6.0 from libmicrohttpd.texi. -This manual is for GNU libmicrohttpd (version 0.9.44, 22 September -2015), a library for embedding an HTTP(S) server into C applications. +This manual is for GNU libmicrohttpd (version 0.9.45, 25 October 2015), +a library for embedding an HTTP(S) server into C applications. Copyright (C) 2007-2013 Christian Grothoff @@ -23,8 +23,8 @@ The GNU libmicrohttpd Library ***************************** -This manual is for GNU libmicrohttpd (version 0.9.44, 22 September -2015), a library for embedding an HTTP(S) server into C applications. +This manual is for GNU libmicrohttpd (version 0.9.45, 25 October 2015), +a library for embedding an HTTP(S) server into C applications. Copyright (C) 2007-2013 Christian Grothoff @@ -1372,7 +1372,9 @@ -- Function: int MHD_get_connection_values (struct MHD_Connection *connection, enum MHD_ValueKind kind, MHD_KeyValueIterator iterator, void *iterator_cls) - Get all the headers matching KIND from the request. + Get all the headers matching KIND from the request. The KIND + argument can be a bitmask, ORing the various header kinds that are + requested. The ITERATOR callback is invoked once for each header, with ITERATOR_CLS as first argument. After version 0.9.19, the headers @@ -1397,8 +1399,8 @@ the string "key". -- Function: int MHD_set_connection_value (struct MHD_Connection - *connection, enum MHD_ValueKind kind, const char * key, const - char * value) + *connection, enum MHD_ValueKind kind, const char *key, const + char *value) This function can be used to append an entry to the list of HTTP headers of a connection (so that the 'MHD_get_connection_values function' will return them - and the MHD PostProcessor will also @@ -4033,7 +4035,7 @@ (line 6) * MHD_is_feature_supported: microhttpd-util feature. (line 75) -* MHD_lookup_connection_value: microhttpd-requests. (line 56) +* MHD_lookup_connection_value: microhttpd-requests. (line 58) * MHD_post_process: microhttpd-post api. (line 33) * MHD_queue_auth_fail_response: microhttpd-dauth digest. (line 35) @@ -4047,7 +4049,7 @@ * MHD_run_from_select: microhttpd-init. (line 86) * MHD_set_connection_option: microhttpd-option conn. (line 6) -* MHD_set_connection_value: microhttpd-requests. (line 33) +* MHD_set_connection_value: microhttpd-requests. (line 35) * MHD_set_panic_func: microhttpd-init. (line 6) * MHD_set_response_options: microhttpd-response options. (line 6) @@ -4090,41 +4092,41 @@ Tag Table: -Node: Top818 -Node: microhttpd-intro3024 -Ref: fig:performance7073 -Ref: tbl:supported8019 -Node: microhttpd-const15292 -Node: microhttpd-struct43050 -Node: microhttpd-cb43830 -Node: microhttpd-init53172 -Node: microhttpd-inspect58926 -Node: microhttpd-requests60863 -Node: microhttpd-responses64347 -Node: microhttpd-response enqueue65459 -Ref: microhttpd-response enqueue-Footnote-167726 -Node: microhttpd-response create67945 -Node: microhttpd-response headers73978 -Node: microhttpd-response options75805 -Node: microhttpd-response inspect76660 -Node: microhttpd-flow77833 -Node: microhttpd-dauth80570 -Node: microhttpd-dauth basic82121 -Node: microhttpd-dauth digest83313 -Node: microhttpd-post87961 -Node: microhttpd-post api90906 -Node: microhttpd-info93490 -Node: microhttpd-info daemon93912 -Node: microhttpd-info conn97317 -Node: microhttpd-option conn101034 -Node: microhttpd-util102098 -Node: microhttpd-util feature102369 -Node: microhttpd-util unescape105810 -Node: GNU-LGPL106450 -Node: GNU GPL with eCos Extension134554 -Node: GNU-FDL154431 -Node: Concept Index179517 -Node: Function and Data Index187607 -Node: Type Index192779 +Node: Top816 +Node: microhttpd-intro3020 +Ref: fig:performance7069 +Ref: tbl:supported8015 +Node: microhttpd-const15288 +Node: microhttpd-struct43046 +Node: microhttpd-cb43826 +Node: microhttpd-init53168 +Node: microhttpd-inspect58922 +Node: microhttpd-requests60859 +Node: microhttpd-responses64439 +Node: microhttpd-response enqueue65551 +Ref: microhttpd-response enqueue-Footnote-167818 +Node: microhttpd-response create68037 +Node: microhttpd-response headers74070 +Node: microhttpd-response options75897 +Node: microhttpd-response inspect76752 +Node: microhttpd-flow77925 +Node: microhttpd-dauth80662 +Node: microhttpd-dauth basic82213 +Node: microhttpd-dauth digest83405 +Node: microhttpd-post88053 +Node: microhttpd-post api90998 +Node: microhttpd-info93582 +Node: microhttpd-info daemon94004 +Node: microhttpd-info conn97409 +Node: microhttpd-option conn101126 +Node: microhttpd-util102190 +Node: microhttpd-util feature102461 +Node: microhttpd-util unescape105902 +Node: GNU-LGPL106542 +Node: GNU GPL with eCos Extension134646 +Node: GNU-FDL154523 +Node: Concept Index179609 +Node: Function and Data Index187699 +Node: Type Index192871 End Tag Table diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/libmicrohttpd-0.9.44/doc/libmicrohttpd.texi new/libmicrohttpd-0.9.45/doc/libmicrohttpd.texi --- old/libmicrohttpd-0.9.44/doc/libmicrohttpd.texi 2015-09-22 19:19:01.000000000 +0200 +++ new/libmicrohttpd-0.9.45/doc/libmicrohttpd.texi 2015-10-25 23:05:19.000000000 +0100 @@ -1578,7 +1578,9 @@ @deftypefun int MHD_get_connection_values (struct MHD_Connection *connection, enum MHD_ValueKind kind, MHD_KeyValueIterator iterator, void *iterator_cls) -Get all the headers matching @var{kind} from the request. +Get all the headers matching @var{kind} from the request. The @var{kind} +argument can be a bitmask, ORing the various header kinds that are +requested. The @var{iterator} callback is invoked once for each header, with @var{iterator_cls} as first argument. After version 0.9.19, the @@ -1604,7 +1606,7 @@ @end deftypefun -@deftypefun int MHD_set_connection_value (struct MHD_Connection *connection, enum MHD_ValueKind kind, const char * key, const char * value) +@deftypefun int MHD_set_connection_value (struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key, const char *value) This function can be used to append an entry to the list of HTTP headers of a connection (so that the @code{MHD_get_connection_values function} will return diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/libmicrohttpd-0.9.44/doc/stamp-vti new/libmicrohttpd-0.9.45/doc/stamp-vti --- old/libmicrohttpd-0.9.44/doc/stamp-vti 2015-10-01 21:22:58.000000000 +0200 +++ new/libmicrohttpd-0.9.45/doc/stamp-vti 2015-10-31 15:53:48.000000000 +0100 @@ -1,4 +1,4 @@ -@set UPDATED 22 September 2015 -@set UPDATED-MONTH September 2015 -@set EDITION 0.9.44 -@set VERSION 0.9.44 +@set UPDATED 25 October 2015 +@set UPDATED-MONTH October 2015 +@set EDITION 0.9.45 +@set VERSION 0.9.45 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/libmicrohttpd-0.9.44/doc/version.texi new/libmicrohttpd-0.9.45/doc/version.texi --- old/libmicrohttpd-0.9.44/doc/version.texi 2015-10-01 21:22:58.000000000 +0200 +++ new/libmicrohttpd-0.9.45/doc/version.texi 2015-10-31 15:53:48.000000000 +0100 @@ -1,4 +1,4 @@ -@set UPDATED 22 September 2015 -@set UPDATED-MONTH September 2015 -@set EDITION 0.9.44 -@set VERSION 0.9.44 +@set UPDATED 25 October 2015 +@set UPDATED-MONTH October 2015 +@set EDITION 0.9.45 +@set VERSION 0.9.45 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/libmicrohttpd-0.9.44/src/include/microhttpd.h new/libmicrohttpd-0.9.45/src/include/microhttpd.h --- old/libmicrohttpd-0.9.44/src/include/microhttpd.h 2015-10-01 21:22:00.000000000 +0200 +++ new/libmicrohttpd-0.9.45/src/include/microhttpd.h 2015-10-31 15:52:49.000000000 +0100 @@ -130,7 +130,7 @@ * Current version of the library. * 0x01093001 = 1.9.30-1. */ -#define MHD_VERSION 0x00094400 +#define MHD_VERSION 0x00094500 /** * MHD-internal return code for "YES". @@ -207,14 +207,20 @@ #define _MHD_INSTRMACRO(a) #a #define _MHD_STRMACRO(a) _MHD_INSTRMACRO(a) #define _MHD_DEPR_MACRO(msg) __pragma(message(__FILE__ "(" _MHD_STRMACRO(__LINE__)"): warning: " msg)) +#define _MHD_DEPR_IN_MACRO(msg) _MHD_DEPR_MACRO(msg) #elif defined(__clang__) || defined (__GNUC_PATCHLEVEL__) #define _MHD_GCC_PRAG(x) _Pragma (#x) #if __clang_major__+0 >= 5 || \ (!defined(__apple_build_version__) && (__clang_major__+0 > 3 || (__clang_major__+0 == 3 && __clang_minor__ >= 3))) || \ __GNUC__+0 > 4 || (__GNUC__+0 == 4 && __GNUC_MINOR__+0 >= 8) #define _MHD_DEPR_MACRO(msg) _MHD_GCC_PRAG(GCC warning msg) +#define _MHD_DEPR_IN_MACRO(msg) _MHD_DEPR_MACRO(msg) #else /* older clang or GCC */ #define _MHD_DEPR_MACRO(msg) _MHD_GCC_PRAG(message msg) +#if (__clang_major__+0 > 2 || (__clang_major__+0 == 2 && __clang_minor__ >= 9)) /* FIXME: earlier versions not tested */ +/* clang handles inline pragmas better than GCC */ +#define _MHD_DEPR_IN_MACRO(msg) _MHD_DEPR_MACRO(msg) +#endif /* clang >= 2.9 */ #endif /* #elif defined(SOMEMACRO) */ /* add compiler-specific macros here if required */ #else /* other compilers */ @@ -222,17 +228,22 @@ #endif #endif /* _MHD_DEPR_MACRO */ +#ifndef _MHD_DEPR_IN_MACRO +#define _MHD_NO_DEPR_IN_MACRO 1 +#define _MHD_DEPR_IN_MACRO(msg) +#endif /* !_MHD_DEPR_IN_MACRO */ + #ifndef _MHD_DEPR_FUNC #if defined(_MSC_FULL_VER) && _MSC_VER+0 >= 1400 #define _MHD_DEPR_FUNC(msg) __declspec(deprecated(msg)) #elif defined(_MSC_FULL_VER) && _MSC_VER+0 >= 1310 /* VS .NET 2003 deprecation do not support custom messages */ #define _MHD_DEPR_FUNC(msg) __declspec(deprecated) -#elif defined (__clang__) && \ - (__clang_major__+0 >= 4 || (!defined(__apple_build_version__) && __clang_major__+0 >= 3)) +#elif (__GNUC__+0 >= 5) || (defined (__clang__) && \ + (__clang_major__+0 > 2 || (__clang_major__+0 == 2 && __clang_minor__ >= 9))) /* FIXME: earlier versions not tested */ #define _MHD_DEPR_FUNC(msg) __attribute__((deprecated(msg))) #elif defined (__clang__) || __GNUC__+0 > 3 || (__GNUC__+0 == 3 && __GNUC_MINOR__+0 >= 1) -/* GCC-style deprecation do not support custom messages */ +/* old GCC-style deprecation do not support custom messages */ #define _MHD_DEPR_FUNC(msg) __attribute__((__deprecated__)) /* #elif defined(SOMEMACRO) */ /* add compiler-specific macros here if required */ #else /* other compilers */ @@ -305,7 +316,7 @@ #define MHD_HTTP_NOT_ACCEPTABLE 406 /** @deprecated */ #define MHD_HTTP_METHOD_NOT_ACCEPTABLE \ - _MHD_DEPR_MACRO("Value MHD_HTTP_METHOD_NOT_ACCEPTABLE is deprecated, use MHD_HTTP_NOT_ACCEPTABLE") 406 + _MHD_DEPR_IN_MACRO("Value MHD_HTTP_METHOD_NOT_ACCEPTABLE is deprecated, use MHD_HTTP_NOT_ACCEPTABLE") 406 #define MHD_HTTP_PROXY_AUTHENTICATION_REQUIRED 407 #define MHD_HTTP_REQUEST_TIMEOUT 408 #define MHD_HTTP_CONFLICT 409 @@ -1777,7 +1788,7 @@ * Get all of the headers from the request. * * @param connection connection to get values from - * @param kind types of values to iterate over + * @param kind types of values to iterate over, can be a bitmask * @param iterator callback to call on each header; * maybe NULL (then just count headers) * @param iterator_cls extra argument to @a iterator @@ -1787,7 +1798,8 @@ _MHD_EXTERN int MHD_get_connection_values (struct MHD_Connection *connection, enum MHD_ValueKind kind, - MHD_KeyValueIterator iterator, void *iterator_cls); + MHD_KeyValueIterator iterator, + void *iterator_cls); /** @@ -2133,11 +2145,13 @@ int fd, off_t offset); +#ifndef _MHD_NO_DEPR_IN_MACRO /* Substitute MHD_create_response_from_fd_at_offset64() instead of MHD_create_response_from_fd_at_offset() to minimize possible problems with different off_t options */ #define MHD_create_response_from_fd_at_offset(size,fd,offset) \ - _MHD_DEPR_MACRO("Usage of MHD_create_response_from_fd_at_offset() is deprecated, use MHD_create_response_from_fd_at_offset64()") \ + _MHD_DEPR_IN_MACRO("Usage of MHD_create_response_from_fd_at_offset() is deprecated, use MHD_create_response_from_fd_at_offset64()") \ MHD_create_response_from_fd_at_offset64((size),(fd),(offset)) +#endif /* ! _MHD_NO_DEPR_IN_MACRO */ /** diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/libmicrohttpd-0.9.44/src/microhttpd/connection.c new/libmicrohttpd-0.9.45/src/microhttpd/connection.c --- old/libmicrohttpd-0.9.44/src/microhttpd/connection.c 2015-10-01 18:31:33.000000000 +0200 +++ new/libmicrohttpd-0.9.45/src/microhttpd/connection.c 2015-10-25 23:04:04.000000000 +0100 @@ -116,7 +116,7 @@ * Get all of the headers from the request. * * @param connection connection to get values from - * @param kind types of values to iterate over + * @param kind types of values to iterate over, can be a bitmask * @param iterator callback to call on each header; * maybe NULL (then just count headers) * @param iterator_cls extra argument to @a iterator @@ -126,7 +126,8 @@ int MHD_get_connection_values (struct MHD_Connection *connection, enum MHD_ValueKind kind, - MHD_KeyValueIterator iterator, void *iterator_cls) + MHD_KeyValueIterator iterator, + void *iterator_cls) { int ret; struct MHD_HTTP_Header *pos; @@ -138,9 +139,11 @@ if (0 != (pos->kind & kind)) { ret++; - if ((NULL != iterator) && - (MHD_YES != iterator (iterator_cls, - kind, pos->header, pos->value))) + if ( (NULL != iterator) && + (MHD_YES != iterator (iterator_cls, + pos->kind, + pos->header, + pos->value)) ) return ret; } return ret; @@ -264,8 +267,8 @@ * @param termination_code termination reason to give */ void -MHD_connection_close (struct MHD_Connection *connection, - enum MHD_RequestTerminationCode termination_code) +MHD_connection_close_ (struct MHD_Connection *connection, + enum MHD_RequestTerminationCode termination_code) { struct MHD_Daemon *daemon; @@ -300,8 +303,8 @@ if (NULL != emsg) MHD_DLOG (connection->daemon, emsg); #endif - MHD_connection_close (connection, - MHD_REQUEST_TERMINATED_WITH_ERROR); + MHD_connection_close_ (connection, + MHD_REQUEST_TERMINATED_WITH_ERROR); } @@ -368,8 +371,8 @@ if (NULL != response->crc) (void) MHD_mutex_unlock_ (&response->mutex); if ( ((ssize_t)MHD_CONTENT_READER_END_OF_STREAM) == ret) - MHD_connection_close (connection, - MHD_REQUEST_TERMINATED_COMPLETED_OK); + MHD_connection_close_ (connection, + MHD_REQUEST_TERMINATED_COMPLETED_OK); else CONNECTION_CLOSE_ERROR (connection, "Closing connection (stream error)\n"); @@ -1176,17 +1179,22 @@ */ static int connection_add_header (struct MHD_Connection *connection, - char *key, char *value, enum MHD_ValueKind kind) + const char *key, + const char *value, + enum MHD_ValueKind kind) { - if (MHD_NO == MHD_set_connection_value (connection, - kind, - key, value)) + if (MHD_NO == + MHD_set_connection_value (connection, + kind, + key, + value)) { #if HAVE_MESSAGES MHD_DLOG (connection->daemon, "Not enough memory to allocate header record!\n"); #endif - transmit_error_response (connection, MHD_HTTP_REQUEST_ENTITY_TOO_LARGE, + transmit_error_response (connection, + MHD_HTTP_REQUEST_ENTITY_TOO_LARGE, REQUEST_TOO_BIG); return MHD_NO; } @@ -1195,98 +1203,9 @@ /** - * Parse and unescape the arguments given by the client as part - * of the HTTP request URI. - * - * @param kind header kind to use for adding to the connection - * @param connection connection to add headers to - * @param args argument URI string (after "?" in URI) - * @return #MHD_NO on failure (out of memory), #MHD_YES for success - */ -static int -parse_arguments (enum MHD_ValueKind kind, - struct MHD_Connection *connection, - char *args) -{ - char *equals; - char *amper; - - while (NULL != args) - { - equals = strchr (args, '='); - amper = strchr (args, '&'); - if (NULL == amper) - { - /* last argument */ - if (NULL == equals) - { - /* got 'foo', add key 'foo' with NULL for value */ - MHD_unescape_plus (args); - connection->daemon->unescape_callback (connection->daemon->unescape_callback_cls, - connection, - args); - return connection_add_header (connection, - args, - NULL, - kind); - } - /* got 'foo=bar' */ - equals[0] = '\0'; - equals++; - MHD_unescape_plus (args); - connection->daemon->unescape_callback (connection->daemon->unescape_callback_cls, - connection, - args); - MHD_unescape_plus (equals); - connection->daemon->unescape_callback (connection->daemon->unescape_callback_cls, - connection, - equals); - return connection_add_header (connection, args, equals, kind); - } - /* amper is non-NULL here */ - amper[0] = '\0'; - amper++; - if ( (NULL == equals) || - (equals >= amper) ) - { - /* got 'foo&bar' or 'foo&bar=val', add key 'foo' with NULL for value */ - MHD_unescape_plus (args); - connection->daemon->unescape_callback (connection->daemon->unescape_callback_cls, - connection, - args); - if (MHD_NO == - connection_add_header (connection, - args, - NULL, - kind)) - return MHD_NO; - /* continue with 'bar' */ - args = amper; - continue; - } - /* equals and amper are non-NULL here, and equals < amper, - so we got regular 'foo=value&bar...'-kind of argument */ - equals[0] = '\0'; - equals++; - MHD_unescape_plus (args); - connection->daemon->unescape_callback (connection->daemon->unescape_callback_cls, - connection, - args); - MHD_unescape_plus (equals); - connection->daemon->unescape_callback (connection->daemon->unescape_callback_cls, - connection, - equals); - if (MHD_NO == connection_add_header (connection, args, equals, kind)) - return MHD_NO; - args = amper; - } - return MHD_YES; -} - - -/** * Parse the cookie header (see RFC 2109). * + * @param connection connection to parse header of * @return #MHD_YES for success, #MHD_NO for failure (malformed, out of memory) */ static int @@ -1372,8 +1291,11 @@ equals[strlen (equals) - 1] = '\0'; equals++; } - if (MHD_NO == connection_add_header (connection, - pos, equals, MHD_COOKIE_KIND)) + if (MHD_NO == + connection_add_header (connection, + pos, + equals, + MHD_COOKIE_KIND)) return MHD_NO; pos = semicolon; } @@ -1392,9 +1314,11 @@ parse_initial_message_line (struct MHD_Connection *connection, char *line) { + struct MHD_Daemon *daemon = connection->daemon; char *uri; char *http_version; char *args; + unsigned int unused_num_headers; if (NULL == (uri = strchr (line, ' '))) return MHD_NO; /* serious error */ @@ -1409,21 +1333,26 @@ http_version[0] = '\0'; http_version++; } - if (NULL != connection->daemon->uri_log_callback) + if (NULL != daemon->uri_log_callback) connection->client_context - = connection->daemon->uri_log_callback (connection->daemon->uri_log_callback_cls, - uri, - connection); + = daemon->uri_log_callback (daemon->uri_log_callback_cls, + uri, + connection); args = strchr (uri, '?'); if (NULL != args) { args[0] = '\0'; args++; - parse_arguments (MHD_GET_ARGUMENT_KIND, connection, args); - } - connection->daemon->unescape_callback (connection->daemon->unescape_callback_cls, - connection, - uri); + /* note that this call clobbers 'args' */ + MHD_parse_arguments_ (connection, + MHD_GET_ARGUMENT_KIND, + args, + &connection_add_header, + &unused_num_headers); + } + daemon->unescape_callback (daemon->unescape_callback_cls, + connection, + uri); connection->url = uri; if (NULL == http_version) connection->version = ""; @@ -1685,8 +1614,8 @@ /* other side closed connection; RFC 2616, section 8.1.4 suggests we should then shutdown ourselves as well. */ connection->read_closed = MHD_YES; - MHD_connection_close (connection, - MHD_REQUEST_TERMINATED_CLIENT_ABORT); + MHD_connection_close_ (connection, + MHD_REQUEST_TERMINATED_CLIENT_ABORT); return MHD_YES; } connection->read_buffer_offset += bytes_read; @@ -1858,7 +1787,9 @@ } EXTRA_CHECK ((NULL != last) && (NULL != connection->colon)); if ((MHD_NO == connection_add_header (connection, - last, connection->colon, kind))) + last, + connection->colon, + kind))) { transmit_error_response (connection, MHD_HTTP_REQUEST_ENTITY_TOO_LARGE, REQUEST_TOO_BIG); @@ -2031,8 +1962,8 @@ /* nothing to do but default action */ if (MHD_YES == connection->read_closed) { - MHD_connection_close (connection, - MHD_REQUEST_TERMINATED_READ_ERROR); + MHD_connection_close_ (connection, + MHD_REQUEST_TERMINATED_READ_ERROR); continue; } break; @@ -2611,8 +2542,8 @@ (MHD_NO == keepalive_possible (connection))) { /* have to close for some reason */ - MHD_connection_close (connection, - MHD_REQUEST_TERMINATED_COMPLETED_OK); + MHD_connection_close_ (connection, + MHD_REQUEST_TERMINATED_COMPLETED_OK); MHD_pool_destroy (connection->pool); connection->pool = NULL; connection->read_buffer = NULL; @@ -2627,7 +2558,7 @@ connection->read_buffer = MHD_pool_reset (connection->pool, connection->read_buffer, - connection->read_buffer_size); + connection->read_buffer_offset); } connection->client_aware = MHD_NO; connection->client_context = NULL; @@ -2657,8 +2588,8 @@ if ( (0 != timeout) && (timeout <= (MHD_monotonic_sec_counter() - connection->last_activity)) ) { - MHD_connection_close (connection, - MHD_REQUEST_TERMINATED_TIMEOUT_REACHED); + MHD_connection_close_ (connection, + MHD_REQUEST_TERMINATED_TIMEOUT_REACHED); connection->in_idle = MHD_NO; return MHD_YES; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/libmicrohttpd-0.9.44/src/microhttpd/connection.h new/libmicrohttpd-0.9.45/src/microhttpd/connection.h --- old/libmicrohttpd-0.9.44/src/microhttpd/connection.h 2015-02-08 00:10:32.000000000 +0100 +++ new/libmicrohttpd-0.9.45/src/microhttpd/connection.h 2015-10-25 14:15:18.000000000 +0100 @@ -89,8 +89,8 @@ * @param termination_code termination reason to give */ void -MHD_connection_close (struct MHD_Connection *connection, - enum MHD_RequestTerminationCode termination_code); +MHD_connection_close_ (struct MHD_Connection *connection, + enum MHD_RequestTerminationCode termination_code); #if EPOLL_SUPPORT diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/libmicrohttpd-0.9.44/src/microhttpd/connection_https.c new/libmicrohttpd-0.9.45/src/microhttpd/connection_https.c --- old/libmicrohttpd-0.9.44/src/microhttpd/connection_https.c 2015-09-13 15:50:21.000000000 +0200 +++ new/libmicrohttpd-0.9.45/src/microhttpd/connection_https.c 2015-10-25 15:28:56.000000000 +0100 @@ -69,8 +69,8 @@ MHD_DLOG (connection->daemon, "Error: received handshake message out of context\n"); #endif - MHD_connection_close (connection, - MHD_REQUEST_TERMINATED_WITH_ERROR); + MHD_connection_close_ (connection, + MHD_REQUEST_TERMINATED_WITH_ERROR); return MHD_YES; } return MHD_NO; @@ -142,8 +142,8 @@ #endif timeout = connection->connection_timeout; if ( (timeout != 0) && (timeout <= (MHD_monotonic_sec_counter() - connection->last_activity))) - MHD_connection_close (connection, - MHD_REQUEST_TERMINATED_TIMEOUT_REACHED); + MHD_connection_close_ (connection, + MHD_REQUEST_TERMINATED_TIMEOUT_REACHED); switch (connection->state) { /* on newly created connections we might reach here before any reply has been received */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/libmicrohttpd-0.9.44/src/microhttpd/daemon.c new/libmicrohttpd-0.9.45/src/microhttpd/daemon.c --- old/libmicrohttpd-0.9.44/src/microhttpd/daemon.c 2015-10-01 18:31:33.000000000 +0200 +++ new/libmicrohttpd-0.9.45/src/microhttpd/daemon.c 2015-10-25 14:59:48.000000000 +0100 @@ -135,7 +135,8 @@ const char *reason) { #if HAVE_MESSAGES - fprintf (stderr, "Fatal error in GNU libmicrohttpd %s:%u: %s\n", + fprintf (stderr, + "Fatal error in GNU libmicrohttpd %s:%u: %s\n", file, line, reason); #endif abort (); @@ -994,7 +995,8 @@ if (0 != (p[0].revents & POLLOUT)) con->write_handler (con); if (0 != (p[0].revents & (POLLERR | POLLHUP))) - MHD_connection_close (con, MHD_REQUEST_TERMINATED_WITH_ERROR); + MHD_connection_close_ (con, + MHD_REQUEST_TERMINATED_WITH_ERROR); if (MHD_NO == con->idle_handler (con)) goto exit; } @@ -1009,8 +1011,8 @@ #endif #endif if (MHD_CONNECTION_CLOSED != con->state) - MHD_connection_close (con, - MHD_REQUEST_TERMINATED_DAEMON_SHUTDOWN); + MHD_connection_close_ (con, + MHD_REQUEST_TERMINATED_DAEMON_SHUTDOWN); con->idle_handler (con); } exit: @@ -1130,12 +1132,12 @@ left = connection->response->total_size - connection->response_write_position; #ifndef HAVE_SENDFILE64 offset = (off_t) offsetu64; - if ( (offsetu64 <= (uint64_t)OFF_T_MAX) && - 0 < (ret = sendfile (connection->socket_fd, fd, &offset, left))) + if ( (offsetu64 <= (uint64_t) OFF_T_MAX) && + (0 < (ret = sendfile (connection->socket_fd, fd, &offset, left))) ) #else /* HAVE_SENDFILE64 */ offset = (off64_t) offsetu64; - if ( (offsetu64 <= (uint64_t)OFF64_T_MAX) && - 0 < (ret = sendfile64 (connection->socket_fd, fd, &offset, left))) + if ( (offsetu64 <= (uint64_t) OFF64_T_MAX) && + (0 < (ret = sendfile64 (connection->socket_fd, fd, &offset, left))) ) #endif /* HAVE_SENDFILE64 */ { #if EPOLL_SUPPORT @@ -4359,8 +4361,8 @@ { struct MHD_Daemon *daemon = pos->daemon; - MHD_connection_close (pos, - MHD_REQUEST_TERMINATED_DAEMON_SHUTDOWN); + MHD_connection_close_ (pos, + MHD_REQUEST_TERMINATED_DAEMON_SHUTDOWN); if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) return; /* must let thread to the rest */ if (pos->connection_timeout == pos->daemon->connection_timeout) @@ -4398,35 +4400,50 @@ if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && (MHD_YES != MHD_mutex_lock_ (&daemon->cleanup_connection_mutex)) ) MHD_PANIC ("Failed to acquire cleanup mutex\n"); + if (NULL != daemon->suspended_connections_head) + MHD_PANIC ("MHD_stop_daemon() called while we have suspended connections.\n"); for (pos = daemon->connections_head; NULL != pos; pos = pos->next) { shutdown (pos->socket_fd, - (pos->read_closed == MHD_YES) ? SHUT_WR : SHUT_RDWR); + (MHD_YES == pos->read_closed) ? SHUT_WR : SHUT_RDWR); #if MHD_WINSOCK_SOCKETS if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && (MHD_INVALID_PIPE_ != daemon->wpipe[1]) && (1 != MHD_pipe_write_ (daemon->wpipe[1], "e", 1)) ) - MHD_PANIC ("failed to signal shutdown via pipe"); + MHD_PANIC ("Failed to signal shutdown via pipe"); #endif } if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && (MHD_YES != MHD_mutex_unlock_ (&daemon->cleanup_connection_mutex)) ) MHD_PANIC ("Failed to release cleanup mutex\n"); - /* now, collect threads from thread pool */ + /* now, collect per-connection threads */ if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) { - for (pos = daemon->connections_head; NULL != pos; pos = pos->next) - { - if (0 != MHD_join_thread_ (pos->pid)) - MHD_PANIC ("Failed to join a thread\n"); - pos->thread_joined = MHD_YES; - } + pos = daemon->connections_head; + while (NULL != pos) + { + if (MHD_YES != pos->thread_joined) + { + if (0 != MHD_join_thread_ (pos->pid)) + MHD_PANIC ("Failed to join a thread\n"); + pos->thread_joined = MHD_YES; + /* The thread may have concurrently modified the DLL, + need to restart from the beginning */ + pos = daemon->connections_head; + continue; + } + pos = pos->next; + } } - /* now that we're alone, move everyone to cleanup */ while (NULL != (pos = daemon->connections_head)) + { + if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && + (MHD_YES != pos->thread_joined) ) + MHD_PANIC ("Failed to join a thread\n"); close_connection (pos); + } MHD_cleanup_connections (daemon); } @@ -4478,7 +4495,7 @@ /* Prepare workers for shutdown */ if (NULL != daemon->worker_pool) { - /* MHD_USE_NO_LISTEN_SOCKET disables thread pools, hence we need to check */ + /* #MHD_USE_NO_LISTEN_SOCKET disables thread pools, hence we need to check */ for (i = 0; i < daemon->worker_pool_size; ++i) { daemon->worker_pool[i].shutdown = MHD_YES; @@ -4556,9 +4573,9 @@ else { /* clean up master threads */ - if ((0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) || - ((0 != (daemon->options & MHD_USE_SELECT_INTERNALLY)) - && (0 == daemon->worker_pool_size))) + if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) || + ( (0 != (daemon->options & MHD_USE_SELECT_INTERNALLY)) && + (0 == daemon->worker_pool_size) ) ) { if (0 != MHD_join_thread_ (daemon->pid)) { @@ -4676,7 +4693,8 @@ * @ingroup logging */ void -MHD_set_panic_func (MHD_PanicCallback cb, void *cls) +MHD_set_panic_func (MHD_PanicCallback cb, + void *cls) { mhd_panic = cb; mhd_panic_cls = cls; @@ -4825,13 +4843,14 @@ #if defined(MHD_USE_POSIX_THREADS) GCRY_THREAD_OPTION_PTHREAD_IMPL; #elif defined(MHD_W32_MUTEX_) -static int gcry_w32_mutex_init (void **ppmtx) + +static int +gcry_w32_mutex_init (void **ppmtx) { *ppmtx = malloc (sizeof (MHD_mutex_)); if (NULL == *ppmtx) return ENOMEM; - if (MHD_YES != MHD_mutex_create_ ((MHD_mutex_*)*ppmtx)) { free (*ppmtx); @@ -4841,13 +4860,30 @@ return 0; } -static int gcry_w32_mutex_destroy (void **ppmtx) - { int res = (MHD_YES == MHD_mutex_destroy_ ((MHD_mutex_*)*ppmtx)) ? 0 : 1; - free (*ppmtx); return res; } -static int gcry_w32_mutex_lock (void **ppmtx) - { return (MHD_YES == MHD_mutex_lock_ ((MHD_mutex_*)*ppmtx)) ? 0 : 1; } -static int gcry_w32_mutex_unlock (void **ppmtx) - { return (MHD_YES == MHD_mutex_unlock_ ((MHD_mutex_*)*ppmtx)) ? 0 : 1; } + + +static int +gcry_w32_mutex_destroy (void **ppmtx) +{ + int res = (MHD_YES == MHD_mutex_destroy_ ((MHD_mutex_*)*ppmtx)) ? 0 : 1; + free (*ppmtx); + return res; +} + + +static int +gcry_w32_mutex_lock (void **ppmtx) +{ + return (MHD_YES == MHD_mutex_lock_ ((MHD_mutex_*)*ppmtx)) ? 0 : 1; +} + + +static int +gcry_w32_mutex_unlock (void **ppmtx) +{ + return (MHD_YES == MHD_mutex_unlock_ ((MHD_mutex_*)*ppmtx)) ? 0 : 1; +} + static struct gcry_thread_cbs gcry_threads_w32 = { (GCRY_THREAD_OPTION_USER | (GCRY_THREAD_OPTION_VERSION << 8)), @@ -4862,7 +4898,8 @@ /** * Initialize do setup work. */ -void MHD_init(void) +void +MHD_init(void) { mhd_panic = &mhd_panic_std; mhd_panic_cls = NULL; @@ -4895,7 +4932,8 @@ } -void MHD_fini(void) +void +MHD_fini(void) { #if HTTPS_SUPPORT gnutls_global_deinit (); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/libmicrohttpd-0.9.44/src/microhttpd/digestauth.c new/libmicrohttpd-0.9.45/src/microhttpd/digestauth.c --- old/libmicrohttpd-0.9.44/src/microhttpd/digestauth.c 2015-10-01 18:31:33.000000000 +0200 +++ new/libmicrohttpd-0.9.45/src/microhttpd/digestauth.c 2015-10-07 21:41:35.000000000 +0200 @@ -443,19 +443,21 @@ * @param connection the connection * @param key the key * @param value the value, can be NULL + * @param kind type of the header * @return #MHD_YES if the key-value pair is in the headers, * #MHD_NO if not */ static int test_header (struct MHD_Connection *connection, const char *key, - const char *value) + const char *value, + enum MHD_ValueKind kind) { struct MHD_HTTP_Header *pos; for (pos = connection->headers_received; NULL != pos; pos = pos->next) { - if (MHD_GET_ARGUMENT_KIND != pos->kind) + if (kind != pos->kind) continue; if (0 != strcmp (key, pos->header)) continue; @@ -488,114 +490,26 @@ { struct MHD_HTTP_Header *pos; char *argb; - char *argp; - char *equals; - char *amper; unsigned int num_headers; + int ret; argb = strdup (args); if (NULL == argb) - { + { #if HAVE_MESSAGES - MHD_DLOG (connection->daemon, - "Failed to allocate memory for copy of URI arguments\n"); + MHD_DLOG (connection->daemon, + "Failed to allocate memory for copy of URI arguments\n"); #endif /* HAVE_MESSAGES */ - return MHD_NO; - } - num_headers = 0; - argp = argb; - while ( (NULL != argp) && - ('\0' != argp[0]) ) - { - equals = strchr (argp, '='); - amper = strchr (argp, '&'); - if (NULL == amper) - { - /* last argument */ - if (NULL == equals) - { - /* last argument, without '=' */ - MHD_unescape_plus (argp); - if (MHD_YES != test_header (connection, - argp, - NULL)) - { - free (argb); - return MHD_NO; - } - num_headers++; - break; - } - /* got 'foo=bar' */ - equals[0] = '\0'; - equals++; - MHD_unescape_plus (argp); - /* add with 'value' NULL */ - connection->daemon->unescape_callback (connection->daemon->unescape_callback_cls, - connection, - argp); - MHD_unescape_plus (equals); - /* add with 'value' NULL */ - connection->daemon->unescape_callback (connection->daemon->unescape_callback_cls, - connection, - equals); - if (MHD_YES != test_header (connection, - argp, - equals)) - { - free (argb); - return MHD_NO; - } - num_headers++; - break; - } - /* amper is non-NULL here */ - amper[0] = '\0'; - amper++; - if ( (NULL == equals) || - (equals >= amper) ) - { - /* got 'foo&bar' or 'foo&bar=val', add key 'foo' with NULL for value */ - MHD_unescape_plus (argp); - connection->daemon->unescape_callback (connection->daemon->unescape_callback_cls, - connection, - argp); - if (MHD_YES != - test_header (connection, - argp, - NULL)) - { - free (argb); - return MHD_NO; - } - /* continue with 'bar' */ - num_headers++; - args = amper; - continue; - } - equals[0] = '\0'; - equals++; - MHD_unescape_plus (argp); - connection->daemon->unescape_callback (connection->daemon->unescape_callback_cls, - connection, - argp); - MHD_unescape_plus (equals); - connection->daemon->unescape_callback (connection->daemon->unescape_callback_cls, - connection, - equals); - if (MHD_YES != - test_header (connection, - argp, - equals)) - { - free (argb); - return MHD_NO; - } - num_headers++; - argp = amper; + return MHD_NO; } + ret = MHD_parse_arguments_ (connection, + MHD_GET_ARGUMENT_KIND, + argb, + &test_header, + &num_headers); free (argb); - + if (MHD_YES != ret) + return MHD_NO; /* also check that the number of headers matches */ for (pos = connection->headers_received; NULL != pos; pos = pos->next) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/libmicrohttpd-0.9.44/src/microhttpd/internal.c new/libmicrohttpd-0.9.45/src/microhttpd/internal.c --- old/libmicrohttpd-0.9.44/src/microhttpd/internal.c 2015-08-30 14:54:17.000000000 +0200 +++ new/libmicrohttpd-0.9.45/src/microhttpd/internal.c 2015-10-07 21:41:35.000000000 +0200 @@ -171,4 +171,116 @@ } +/** + * Parse and unescape the arguments given by the client + * as part of the HTTP request URI. + * + * @param kind header kind to pass to @a cb + * @param connection connection to add headers to + * @param[in|out] args argument URI string (after "?" in URI), + * clobbered in the process! + * @param cb function to call on each key-value pair found + * @param[out] num_headers set to the number of headers found + * @return #MHD_NO on failure (@a cb returned #MHD_NO), + * #MHD_YES for success (parsing succeeded, @a cb always + * returned #MHD_YES) + */ +int +MHD_parse_arguments_ (struct MHD_Connection *connection, + enum MHD_ValueKind kind, + char *args, + MHD_ArgumentIterator_ cb, + unsigned int *num_headers) +{ + struct MHD_Daemon *daemon = connection->daemon; + char *equals; + char *amper; + + *num_headers = 0; + while ( (NULL != args) && + ('\0' != args[0]) ) + { + equals = strchr (args, '='); + amper = strchr (args, '&'); + if (NULL == amper) + { + /* last argument */ + if (NULL == equals) + { + /* last argument, without '=' */ + MHD_unescape_plus (args); + daemon->unescape_callback (daemon->unescape_callback_cls, + connection, + args); + if (MHD_YES != cb (connection, + args, + NULL, + kind)) + return MHD_NO; + (*num_headers)++; + break; + } + /* got 'foo=bar' */ + equals[0] = '\0'; + equals++; + MHD_unescape_plus (args); + daemon->unescape_callback (daemon->unescape_callback_cls, + connection, + args); + MHD_unescape_plus (equals); + daemon->unescape_callback (daemon->unescape_callback_cls, + connection, + equals); + if (MHD_YES != cb (connection, + args, + equals, + kind)) + return MHD_NO; + (*num_headers)++; + break; + } + /* amper is non-NULL here */ + amper[0] = '\0'; + amper++; + if ( (NULL == equals) || + (equals >= amper) ) + { + /* got 'foo&bar' or 'foo&bar=val', add key 'foo' with NULL for value */ + MHD_unescape_plus (args); + daemon->unescape_callback (daemon->unescape_callback_cls, + connection, + args); + if (MHD_YES != cb (connection, + args, + NULL, + kind)) + return MHD_NO; + /* continue with 'bar' */ + (*num_headers)++; + args = amper; + continue; + } + /* equals and amper are non-NULL here, and equals < amper, + so we got regular 'foo=value&bar...'-kind of argument */ + equals[0] = '\0'; + equals++; + MHD_unescape_plus (args); + daemon->unescape_callback (daemon->unescape_callback_cls, + connection, + args); + MHD_unescape_plus (equals); + daemon->unescape_callback (daemon->unescape_callback_cls, + connection, + equals); + if (MHD_YES != cb (connection, + args, + equals, + kind)) + return MHD_NO; + (*num_headers)++; + args = amper; + } + return MHD_YES; +} + /* end of internal.c */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/libmicrohttpd-0.9.44/src/microhttpd/internal.h new/libmicrohttpd-0.9.45/src/microhttpd/internal.h --- old/libmicrohttpd-0.9.44/src/microhttpd/internal.h 2015-08-30 14:54:17.000000000 +0200 +++ new/libmicrohttpd-0.9.45/src/microhttpd/internal.h 2015-10-25 13:58:35.000000000 +0100 @@ -109,19 +109,19 @@ { /** - * The socket is not involved with a defined state in epoll right + * The socket is not involved with a defined state in epoll() right * now. */ MHD_EPOLL_STATE_UNREADY = 0, /** - * epoll told us that data was ready for reading, and we did + * epoll() told us that data was ready for reading, and we did * not consume all of it yet. */ MHD_EPOLL_STATE_READ_READY = 1, /** - * epoll told us that space was available for writing, and we did + * epoll() told us that space was available for writing, and we did * not consume all of it yet. */ MHD_EPOLL_STATE_WRITE_READY = 2, @@ -132,7 +132,7 @@ MHD_EPOLL_STATE_IN_EREADY_EDLL = 4, /** - * Is this connection currently in the 'epoll' set? + * Is this connection currently in the epoll() set? */ MHD_EPOLL_STATE_IN_EPOLL_SET = 8, @@ -201,7 +201,7 @@ #if HAVE_MESSAGES /** - * fprintf-like helper function for logging debug + * fprintf()-like helper function for logging debug * messages. */ void @@ -311,8 +311,8 @@ size_t data_buffer_size; /** - * Reference count for this response. Free - * once the counter hits zero. + * Reference count for this response. Free once the counter hits + * zero. */ unsigned int reference_count; @@ -332,16 +332,17 @@ /** * States in a state machine for a connection. * - * Transitions are any-state to CLOSED, any state to state+1, - * FOOTERS_SENT to INIT. CLOSED is the terminal state and - * INIT the initial state. + * The main transitions are any-state to #MHD_CONNECTION_CLOSED, any + * state to state+1, #MHD_CONNECTION_FOOTERS_SENT to + * #MHD_CONNECTION_INIT. #MHD_CONNECTION_CLOSED is the terminal state + * and #MHD_CONNECTION_INIT the initial state. * - * Note that transitions for *reading* happen only after - * the input has been processed; transitions for - * *writing* happen after the respective data has been - * put into the write buffer (the write does not have - * to be completed yet). A transition to CLOSED or INIT - * requires the write to be complete. + * Note that transitions for *reading* happen only after the input has + * been processed; transitions for *writing* happen after the + * respective data has been put into the write buffer (the write does + * not have to be completed yet). A transition to + * #MHD_CONNECTION_CLOSED or #MHD_CONNECTION_INIT requires the write + * to be complete. */ enum MHD_CONNECTION_STATE { @@ -462,7 +463,7 @@ /** * The initial connection state for all secure connectoins * Handshake messages will be processed in this state & while - * in the 'MHD_TLS_HELLO_REQUEST' state + * in the #MHD_TLS_HELLO_REQUEST state */ MHD_TLS_CONNECTION_INIT = MHD_CONNECTION_IN_CLEANUP + 1 @@ -487,7 +488,7 @@ * @param conn the connection struct * @param write_to where to write received data * @param max_bytes maximum number of bytes to receive - * @return number of bytes written to write_to + * @return number of bytes written to @a write_to */ typedef ssize_t (*ReceiveCallback) (struct MHD_Connection *conn, @@ -662,7 +663,7 @@ MHD_thread_handle_ pid; /** - * Size of read_buffer (in bytes). This value indicates + * Size of @e read_buffer (in bytes). This value indicates * how many bytes we're willing to read into the buffer; * the real buffer is one byte longer to allow for * adding zero-termination (when needed). @@ -671,12 +672,12 @@ /** * Position where we currently append data in - * read_buffer (last valid position). + * @e read_buffer (last valid position). */ size_t read_buffer_offset; /** - * Size of write_buffer (in bytes). + * Size of @e write_buffer (in bytes). */ size_t write_buffer_size; @@ -728,8 +729,8 @@ unsigned int connection_timeout; /** - * Did we ever call the "default_handler" on this connection? - * (this flag will determine if we call the 'notify_completed' + * Did we ever call the "default_handler" on this connection? (this + * flag will determine if we call the #MHD_OPTION_NOTIFY_COMPLETED * handler when the connection closes down). */ int client_aware; @@ -755,7 +756,8 @@ int thread_joined; /** - * Are we currently inside the "idle" handler (to avoid recursively invoking it). + * Are we currently inside the "idle" handler (to avoid recursively + * invoking it). */ int in_idle; @@ -783,7 +785,7 @@ unsigned int responseCode; /** - * Set to MHD_YES if the response's content reader + * Set to #MHD_YES if the response's content reader * callback failed to provide data the last time * we tried to read from it. In that case, the * write socket should be marked as unready until @@ -793,10 +795,10 @@ /** * Are we receiving with chunked encoding? This will be set to - * MHD_YES after we parse the headers and are processing the body + * #MHD_YES after we parse the headers and are processing the body * with chunks. After we are done with the body and we are * processing the footers; once the footers are also done, this will - * be set to MHD_NO again (before the final call to the handler). + * be set to #MHD_NO again (before the final call to the handler). */ int have_chunked_upload; @@ -882,8 +884,8 @@ * @return new closure */ typedef void * -(*LogCallback)(void * cls, - const char * uri, +(*LogCallback)(void *cls, + const char *uri, struct MHD_Connection *con); /** @@ -972,8 +974,8 @@ * moved back to the tail of the list. * * All connections by default start in this list; if a custom - * timeout that does not match 'connection_timeout' is set, they - * are moved to the 'manual_timeout_head'-XDLL. + * timeout that does not match @e connection_timeout is set, they + * are moved to the @e manual_timeout_head-XDLL. */ struct MHD_Connection *normal_timeout_head; @@ -1014,7 +1016,7 @@ MHD_RequestCompletedCallback notify_completed; /** - * Closure argument to notify_completed. + * Closure argument to @e notify_completed. */ void *notify_completed_cls; @@ -1025,7 +1027,7 @@ MHD_NotifyConnectionCallback notify_connection; /** - * Closure argument to notify_connection. + * Closure argument to @e notify_connection. */ void *notify_connection_cls; @@ -1061,7 +1063,7 @@ void (*custom_error_log) (void *cls, const char *fmt, va_list va); /** - * Closure argument to custom_error_log. + * Closure argument to @e custom_error_log. */ void *custom_error_log_cls; #endif @@ -1447,4 +1449,44 @@ MHD_unescape_plus (char *arg); +/** + * Callback invoked when iterating over @a key / @a value + * argument pairs during parsing. + * + * @param connection context of the iteration + * @param key 0-terminated key string, never NULL + * @param value 0-terminated value string, may be NULL + * @param kind origin of the key-value pair + * @return #MHD_YES on success (continue to iterate) + * #MHD_NO to signal failure (and abort iteration) + */ +typedef int +(*MHD_ArgumentIterator_)(struct MHD_Connection *connection, + const char *key, + const char *value, + enum MHD_ValueKind kind); + + +/** + * Parse and unescape the arguments given by the client + * as part of the HTTP request URI. + * + * @param kind header kind to pass to @a cb + * @param connection connection to add headers to + * @param[in|out] args argument URI string (after "?" in URI), + * clobbered in the process! + * @param cb function to call on each key-value pair found + * @param[out] num_headers set to the number of headers found + * @return #MHD_NO on failure (@a cb returned #MHD_NO), + * #MHD_YES for success (parsing succeeded, @a cb always + * returned #MHD_YES) + */ +int +MHD_parse_arguments_ (struct MHD_Connection *connection, + enum MHD_ValueKind kind, + char *args, + MHD_ArgumentIterator_ cb, + unsigned int *num_headers); + + #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/libmicrohttpd-0.9.44/src/microhttpd/memorypool.c new/libmicrohttpd-0.9.45/src/microhttpd/memorypool.c --- old/libmicrohttpd-0.9.44/src/microhttpd/memorypool.c 2015-02-08 00:10:32.000000000 +0100 +++ new/libmicrohttpd-0.9.45/src/microhttpd/memorypool.c 2015-10-31 15:51:30.000000000 +0100 @@ -240,7 +240,7 @@ { /* fits */ ret = &pool->memory[pool->pos]; - memcpy (ret, old, old_size); + memmove (ret, old, old_size); pool->pos += asize; return ret; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/libmicrohttpd-0.9.44/src/microhttpd/memorypool.h new/libmicrohttpd-0.9.45/src/microhttpd/memorypool.h --- old/libmicrohttpd-0.9.44/src/microhttpd/memorypool.h 2015-02-08 00:10:32.000000000 +0100 +++ new/libmicrohttpd-0.9.45/src/microhttpd/memorypool.h 2015-10-20 00:11:02.000000000 +0200 @@ -62,7 +62,7 @@ * * @param pool memory pool to use for the operation * @param size number of bytes to allocate - * @param from_end allocate from end of pool (set to MHD_YES); + * @param from_end allocate from end of pool (set to #MHD_YES); * use this for small, persistent allocations that * will never be reallocated * @return NULL if the pool cannot support size more diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/libmicrohttpd-0.9.44/src/testcurl/test_concurrent_stop.c new/libmicrohttpd-0.9.45/src/testcurl/test_concurrent_stop.c --- old/libmicrohttpd-0.9.44/src/testcurl/test_concurrent_stop.c 2015-06-30 21:11:10.000000000 +0200 +++ new/libmicrohttpd-0.9.45/src/testcurl/test_concurrent_stop.c 2015-10-25 14:13:14.000000000 +0100 @@ -68,13 +68,15 @@ return size * nmemb; } + static int ahc_echo (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, - const char *upload_data, size_t *upload_data_size, + const char *upload_data, + size_t *upload_data_size, void **unused) { static int ptr; @@ -166,7 +168,8 @@ static int -testMultithreadedGet (int port, int poll_flag) +testMultithreadedGet (int port, + int poll_flag) { struct MHD_Daemon *d; pid_t p; @@ -184,7 +187,8 @@ static int -testMultithreadedPoolGet (int port, int poll_flag) +testMultithreadedPoolGet (int port, + int poll_flag) { struct MHD_Daemon *d; pid_t p; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/libmicrohttpd-0.9.44/w32/VS2013/microhttpd_dll_res_vc.rc new/libmicrohttpd-0.9.45/w32/VS2013/microhttpd_dll_res_vc.rc --- old/libmicrohttpd-0.9.44/w32/VS2013/microhttpd_dll_res_vc.rc 2015-10-01 21:22:43.000000000 +0200 +++ new/libmicrohttpd-0.9.45/w32/VS2013/microhttpd_dll_res_vc.rc 2015-10-31 15:53:36.000000000 +0100 @@ -4,8 +4,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,9,44,0 - PRODUCTVERSION 0,9,44,0 + FILEVERSION 0,9,45,0 + PRODUCTVERSION 0,9,45,0 FILEFLAGSMASK VS_FFI_FILEFLAGSMASK #if defined(_DEBUG) FILEFLAGS VS_FF_DEBUG @@ -21,8 +21,8 @@ BLOCK "04090000" /* Lang = US English, Charset = ASCII */ BEGIN VALUE "ProductName", "GNU libmicrohttpd\0" - VALUE "ProductVersion", "0.9.44\0" - VALUE "FileVersion", "0.9.44\0" + VALUE "ProductVersion", "0.9.45\0" + VALUE "FileVersion", "0.9.45\0" VALUE "FileDescription", "GNU libmicrohttpd dll for Windows (VC build)\0" VALUE "InternalName", "libmicrohttpd\0" #if defined(_DEBUG)