libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit 38fad29b451f60898f2bbbaccc39dc97b86f5fe2
parent d9999d665031980a27b30246b40ce45d8813c82f
Author: Christian Grothoff <christian@grothoff.org>
Date:   Fri,  6 Dec 2013 23:45:41 +0000

-fix build issue without HTTPS and compiler warnings, as reported by   Dilyan Palauzov
on the mailinglist

Diffstat:
MChangeLog | 4++++
Msrc/include/microhttpd.h | 2+-
Msrc/microhttpd/connection.c | 13+++++++------
Msrc/microhttpd/internal.h | 32++++++++++++++++----------------
4 files changed, 28 insertions(+), 23 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,7 @@ +Sat Dec 7 00:44:49 CET 2013 + Fixing warnings and build issue if --disable-https is given + to configure. -CG + Tue Dec 3 21:25:56 CET 2013 Security fix: do not read past 0-terminator when unescaping strings (thanks to Florian Weimer for reporting). diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h @@ -121,7 +121,7 @@ extern "C" * Current version of the library. * 0x01093001 = 1.9.30-1. */ -#define MHD_VERSION 0x00093200 +#define MHD_VERSION 0x00093201 /** * MHD-internal return code for "YES". diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c @@ -352,14 +352,14 @@ try_ready_normal_body (struct MHD_Connection *connection) MHD_MIN (response->data_buffer_size, response->total_size - connection->response_write_position)); - if ( (MHD_CONTENT_READER_END_OF_STREAM == ret) || - (MHD_CONTENT_READER_END_WITH_ERROR == ret) ) + if ( (((ssize_t) MHD_CONTENT_READER_END_OF_STREAM) == ret) || + (((ssize_t) MHD_CONTENT_READER_END_WITH_ERROR) == ret) ) { /* either error or http 1.0 transfer, close socket! */ response->total_size = connection->response_write_position; if (NULL != response->crc) pthread_mutex_unlock (&response->mutex); - if (MHD_CONTENT_READER_END_OF_STREAM == ret) + if ( ((ssize_t)MHD_CONTENT_READER_END_OF_STREAM) == ret) MHD_connection_close (connection, MHD_REQUEST_TERMINATED_COMPLETED_OK); else CONNECTION_CLOSE_ERROR (connection, @@ -426,7 +426,8 @@ try_ready_chunked_body (struct MHD_Connection *connection) { /* buffer already ready, use what is there for the chunk */ ret = response->data_size + response->data_start - connection->response_write_position; - if (ret > connection->write_buffer_size - sizeof (cbuf) - 2) + if ( (ret > 0) && + (((size_t) ret) > connection->write_buffer_size - sizeof (cbuf) - 2) ) ret = connection->write_buffer_size - sizeof (cbuf) - 2; memcpy (&connection->write_buffer[sizeof (cbuf)], &response->data[connection->response_write_position - response->data_start], @@ -443,7 +444,7 @@ try_ready_chunked_body (struct MHD_Connection *connection) &connection->write_buffer[sizeof (cbuf)], connection->write_buffer_size - sizeof (cbuf) - 2); } - if (MHD_CONTENT_READER_END_WITH_ERROR == ret) + if ( ((ssize_t) MHD_CONTENT_READER_END_WITH_ERROR) == ret) { /* error, close socket! */ response->total_size = connection->response_write_position; @@ -451,7 +452,7 @@ try_ready_chunked_body (struct MHD_Connection *connection) "Closing connection (error generating response)\n"); return MHD_NO; } - if ( (MHD_CONTENT_READER_END_OF_STREAM == ret) || + if ( (((ssize_t) MHD_CONTENT_READER_END_OF_STREAM) == ret) || (0 == response->total_size) ) { /* end of message, signal other side! */ diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h @@ -1,17 +1,17 @@ /* This file is part of libmicrohttpd (C) 2007-2013 Daniel Pittman and Christian Grothoff - + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA @@ -70,14 +70,14 @@ extern void *mhd_panic_cls; #if HAVE_MESSAGES /** * Trigger 'panic' action based on fatal errors. - * + * * @param msg error message (const char *) */ #define MHD_PANIC(msg) mhd_panic (mhd_panic_cls, __FILE__, __LINE__, msg) #else /** * Trigger 'panic' action based on fatal errors. - * + * * @param msg error message (const char *) */ #define MHD_PANIC(msg) mhd_panic (mhd_panic_cls, __FILE__, __LINE__, NULL) @@ -142,12 +142,12 @@ enum MHD_ConnectionEventLoopInfo /** * We are waiting for the application to provide data. - */ + */ MHD_EVENT_LOOP_INFO_BLOCK = 2, /** * We are finished and are awaiting cleanup. - */ + */ MHD_EVENT_LOOP_INFO_CLEANUP = 3 }; @@ -165,9 +165,9 @@ enum MHD_ConnectionEventLoopInfo * A structure representing the internal holder of the * nonce-nc map. */ -struct MHD_NonceNc +struct MHD_NonceNc { - + /** * Nonce counter, a value that increases for each subsequent * request for the same nonce. @@ -175,7 +175,7 @@ struct MHD_NonceNc unsigned long int nc; /** - * Nonce value: + * Nonce value: */ char nonce[MAX_NONCE_LENGTH]; @@ -186,8 +186,8 @@ struct MHD_NonceNc * fprintf-like helper function for logging debug * messages. */ -void -MHD_DLOG (const struct MHD_Daemon *daemon, +void +MHD_DLOG (const struct MHD_Daemon *daemon, const char *format, ...); #endif @@ -202,7 +202,7 @@ MHD_DLOG (const struct MHD_Daemon *daemon, * @return length of the resulting val (strlen(val) maybe * shorter afterwards due to elimination of escape sequences) */ -size_t +size_t MHD_http_unescape (void *cls, struct MHD_Connection *connection, char *val); @@ -833,6 +833,7 @@ struct MHD_Connection * even though the socket is not? */ int tls_read_ready; +#endif /** * Is the connection suspended? @@ -843,7 +844,6 @@ struct MHD_Connection * Is the connection wanting to resume? */ int resuming; -#endif }; /** @@ -854,7 +854,7 @@ struct MHD_Connection * @param con connection handle * @return new closure */ -typedef void * (*LogCallback)(void * cls, +typedef void * (*LogCallback)(void * cls, const char * uri, struct MHD_Connection *con); @@ -1088,7 +1088,7 @@ struct MHD_Daemon int epoll_fd; /** - * MHD_YES if the listen socket is in the 'epoll' set, + * MHD_YES if the listen socket is in the 'epoll' set, * MHD_NO if not. */ int listen_socket_in_epoll;