diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-12-06 23:45:41 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-12-06 23:45:41 +0000 |
commit | 38fad29b451f60898f2bbbaccc39dc97b86f5fe2 (patch) | |
tree | c14c9741bf08b51e80b562856fc9cf64ed59bf8b | |
parent | d9999d665031980a27b30246b40ce45d8813c82f (diff) | |
download | libmicrohttpd-38fad29b451f60898f2bbbaccc39dc97b86f5fe2.tar.gz libmicrohttpd-38fad29b451f60898f2bbbaccc39dc97b86f5fe2.zip |
-fix build issue without HTTPS and compiler warnings, as reported by Dilyan Palauzov
on the mailinglist
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | src/include/microhttpd.h | 2 | ||||
-rw-r--r-- | src/microhttpd/connection.c | 13 | ||||
-rw-r--r-- | src/microhttpd/internal.h | 32 |
4 files changed, 28 insertions, 23 deletions
@@ -1,3 +1,7 @@ | |||
1 | Sat Dec 7 00:44:49 CET 2013 | ||
2 | Fixing warnings and build issue if --disable-https is given | ||
3 | to configure. -CG | ||
4 | |||
1 | Tue Dec 3 21:25:56 CET 2013 | 5 | Tue Dec 3 21:25:56 CET 2013 |
2 | Security fix: do not read past 0-terminator when unescaping | 6 | Security fix: do not read past 0-terminator when unescaping |
3 | strings (thanks to Florian Weimer for reporting). | 7 | strings (thanks to Florian Weimer for reporting). |
diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h index e6a7532c..2fddf6c9 100644 --- a/src/include/microhttpd.h +++ b/src/include/microhttpd.h | |||
@@ -121,7 +121,7 @@ extern "C" | |||
121 | * Current version of the library. | 121 | * Current version of the library. |
122 | * 0x01093001 = 1.9.30-1. | 122 | * 0x01093001 = 1.9.30-1. |
123 | */ | 123 | */ |
124 | #define MHD_VERSION 0x00093200 | 124 | #define MHD_VERSION 0x00093201 |
125 | 125 | ||
126 | /** | 126 | /** |
127 | * MHD-internal return code for "YES". | 127 | * MHD-internal return code for "YES". |
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c index de478c86..f8059dbc 100644 --- a/src/microhttpd/connection.c +++ b/src/microhttpd/connection.c | |||
@@ -352,14 +352,14 @@ try_ready_normal_body (struct MHD_Connection *connection) | |||
352 | MHD_MIN (response->data_buffer_size, | 352 | MHD_MIN (response->data_buffer_size, |
353 | response->total_size - | 353 | response->total_size - |
354 | connection->response_write_position)); | 354 | connection->response_write_position)); |
355 | if ( (MHD_CONTENT_READER_END_OF_STREAM == ret) || | 355 | if ( (((ssize_t) MHD_CONTENT_READER_END_OF_STREAM) == ret) || |
356 | (MHD_CONTENT_READER_END_WITH_ERROR == ret) ) | 356 | (((ssize_t) MHD_CONTENT_READER_END_WITH_ERROR) == ret) ) |
357 | { | 357 | { |
358 | /* either error or http 1.0 transfer, close socket! */ | 358 | /* either error or http 1.0 transfer, close socket! */ |
359 | response->total_size = connection->response_write_position; | 359 | response->total_size = connection->response_write_position; |
360 | if (NULL != response->crc) | 360 | if (NULL != response->crc) |
361 | pthread_mutex_unlock (&response->mutex); | 361 | pthread_mutex_unlock (&response->mutex); |
362 | if (MHD_CONTENT_READER_END_OF_STREAM == ret) | 362 | if ( ((ssize_t)MHD_CONTENT_READER_END_OF_STREAM) == ret) |
363 | MHD_connection_close (connection, MHD_REQUEST_TERMINATED_COMPLETED_OK); | 363 | MHD_connection_close (connection, MHD_REQUEST_TERMINATED_COMPLETED_OK); |
364 | else | 364 | else |
365 | CONNECTION_CLOSE_ERROR (connection, | 365 | CONNECTION_CLOSE_ERROR (connection, |
@@ -426,7 +426,8 @@ try_ready_chunked_body (struct MHD_Connection *connection) | |||
426 | { | 426 | { |
427 | /* buffer already ready, use what is there for the chunk */ | 427 | /* buffer already ready, use what is there for the chunk */ |
428 | ret = response->data_size + response->data_start - connection->response_write_position; | 428 | ret = response->data_size + response->data_start - connection->response_write_position; |
429 | if (ret > connection->write_buffer_size - sizeof (cbuf) - 2) | 429 | if ( (ret > 0) && |
430 | (((size_t) ret) > connection->write_buffer_size - sizeof (cbuf) - 2) ) | ||
430 | ret = connection->write_buffer_size - sizeof (cbuf) - 2; | 431 | ret = connection->write_buffer_size - sizeof (cbuf) - 2; |
431 | memcpy (&connection->write_buffer[sizeof (cbuf)], | 432 | memcpy (&connection->write_buffer[sizeof (cbuf)], |
432 | &response->data[connection->response_write_position - response->data_start], | 433 | &response->data[connection->response_write_position - response->data_start], |
@@ -443,7 +444,7 @@ try_ready_chunked_body (struct MHD_Connection *connection) | |||
443 | &connection->write_buffer[sizeof (cbuf)], | 444 | &connection->write_buffer[sizeof (cbuf)], |
444 | connection->write_buffer_size - sizeof (cbuf) - 2); | 445 | connection->write_buffer_size - sizeof (cbuf) - 2); |
445 | } | 446 | } |
446 | if (MHD_CONTENT_READER_END_WITH_ERROR == ret) | 447 | if ( ((ssize_t) MHD_CONTENT_READER_END_WITH_ERROR) == ret) |
447 | { | 448 | { |
448 | /* error, close socket! */ | 449 | /* error, close socket! */ |
449 | response->total_size = connection->response_write_position; | 450 | response->total_size = connection->response_write_position; |
@@ -451,7 +452,7 @@ try_ready_chunked_body (struct MHD_Connection *connection) | |||
451 | "Closing connection (error generating response)\n"); | 452 | "Closing connection (error generating response)\n"); |
452 | return MHD_NO; | 453 | return MHD_NO; |
453 | } | 454 | } |
454 | if ( (MHD_CONTENT_READER_END_OF_STREAM == ret) || | 455 | if ( (((ssize_t) MHD_CONTENT_READER_END_OF_STREAM) == ret) || |
455 | (0 == response->total_size) ) | 456 | (0 == response->total_size) ) |
456 | { | 457 | { |
457 | /* end of message, signal other side! */ | 458 | /* end of message, signal other side! */ |
diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h index feee0aab..861ff39f 100644 --- a/src/microhttpd/internal.h +++ b/src/microhttpd/internal.h | |||
@@ -1,17 +1,17 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libmicrohttpd | 2 | This file is part of libmicrohttpd |
3 | (C) 2007-2013 Daniel Pittman and Christian Grothoff | 3 | (C) 2007-2013 Daniel Pittman and Christian Grothoff |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Lesser General Public | 6 | modify it under the terms of the GNU Lesser General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2.1 of the License, or (at your option) any later version. | 8 | version 2.1 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Lesser General Public License for more details. | 13 | Lesser General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Lesser General Public | 15 | You should have received a copy of the GNU Lesser General Public |
16 | License along with this library; if not, write to the Free Software | 16 | License along with this library; if not, write to the Free Software |
17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
@@ -70,14 +70,14 @@ extern void *mhd_panic_cls; | |||
70 | #if HAVE_MESSAGES | 70 | #if HAVE_MESSAGES |
71 | /** | 71 | /** |
72 | * Trigger 'panic' action based on fatal errors. | 72 | * Trigger 'panic' action based on fatal errors. |
73 | * | 73 | * |
74 | * @param msg error message (const char *) | 74 | * @param msg error message (const char *) |
75 | */ | 75 | */ |
76 | #define MHD_PANIC(msg) mhd_panic (mhd_panic_cls, __FILE__, __LINE__, msg) | 76 | #define MHD_PANIC(msg) mhd_panic (mhd_panic_cls, __FILE__, __LINE__, msg) |
77 | #else | 77 | #else |
78 | /** | 78 | /** |
79 | * Trigger 'panic' action based on fatal errors. | 79 | * Trigger 'panic' action based on fatal errors. |
80 | * | 80 | * |
81 | * @param msg error message (const char *) | 81 | * @param msg error message (const char *) |
82 | */ | 82 | */ |
83 | #define MHD_PANIC(msg) mhd_panic (mhd_panic_cls, __FILE__, __LINE__, NULL) | 83 | #define MHD_PANIC(msg) mhd_panic (mhd_panic_cls, __FILE__, __LINE__, NULL) |
@@ -142,12 +142,12 @@ enum MHD_ConnectionEventLoopInfo | |||
142 | 142 | ||
143 | /** | 143 | /** |
144 | * We are waiting for the application to provide data. | 144 | * We are waiting for the application to provide data. |
145 | */ | 145 | */ |
146 | MHD_EVENT_LOOP_INFO_BLOCK = 2, | 146 | MHD_EVENT_LOOP_INFO_BLOCK = 2, |
147 | 147 | ||
148 | /** | 148 | /** |
149 | * We are finished and are awaiting cleanup. | 149 | * We are finished and are awaiting cleanup. |
150 | */ | 150 | */ |
151 | MHD_EVENT_LOOP_INFO_CLEANUP = 3 | 151 | MHD_EVENT_LOOP_INFO_CLEANUP = 3 |
152 | }; | 152 | }; |
153 | 153 | ||
@@ -165,9 +165,9 @@ enum MHD_ConnectionEventLoopInfo | |||
165 | * A structure representing the internal holder of the | 165 | * A structure representing the internal holder of the |
166 | * nonce-nc map. | 166 | * nonce-nc map. |
167 | */ | 167 | */ |
168 | struct MHD_NonceNc | 168 | struct MHD_NonceNc |
169 | { | 169 | { |
170 | 170 | ||
171 | /** | 171 | /** |
172 | * Nonce counter, a value that increases for each subsequent | 172 | * Nonce counter, a value that increases for each subsequent |
173 | * request for the same nonce. | 173 | * request for the same nonce. |
@@ -175,7 +175,7 @@ struct MHD_NonceNc | |||
175 | unsigned long int nc; | 175 | unsigned long int nc; |
176 | 176 | ||
177 | /** | 177 | /** |
178 | * Nonce value: | 178 | * Nonce value: |
179 | */ | 179 | */ |
180 | char nonce[MAX_NONCE_LENGTH]; | 180 | char nonce[MAX_NONCE_LENGTH]; |
181 | 181 | ||
@@ -186,8 +186,8 @@ struct MHD_NonceNc | |||
186 | * fprintf-like helper function for logging debug | 186 | * fprintf-like helper function for logging debug |
187 | * messages. | 187 | * messages. |
188 | */ | 188 | */ |
189 | void | 189 | void |
190 | MHD_DLOG (const struct MHD_Daemon *daemon, | 190 | MHD_DLOG (const struct MHD_Daemon *daemon, |
191 | const char *format, ...); | 191 | const char *format, ...); |
192 | #endif | 192 | #endif |
193 | 193 | ||
@@ -202,7 +202,7 @@ MHD_DLOG (const struct MHD_Daemon *daemon, | |||
202 | * @return length of the resulting val (strlen(val) maybe | 202 | * @return length of the resulting val (strlen(val) maybe |
203 | * shorter afterwards due to elimination of escape sequences) | 203 | * shorter afterwards due to elimination of escape sequences) |
204 | */ | 204 | */ |
205 | size_t | 205 | size_t |
206 | MHD_http_unescape (void *cls, | 206 | MHD_http_unescape (void *cls, |
207 | struct MHD_Connection *connection, | 207 | struct MHD_Connection *connection, |
208 | char *val); | 208 | char *val); |
@@ -833,6 +833,7 @@ struct MHD_Connection | |||
833 | * even though the socket is not? | 833 | * even though the socket is not? |
834 | */ | 834 | */ |
835 | int tls_read_ready; | 835 | int tls_read_ready; |
836 | #endif | ||
836 | 837 | ||
837 | /** | 838 | /** |
838 | * Is the connection suspended? | 839 | * Is the connection suspended? |
@@ -843,7 +844,6 @@ struct MHD_Connection | |||
843 | * Is the connection wanting to resume? | 844 | * Is the connection wanting to resume? |
844 | */ | 845 | */ |
845 | int resuming; | 846 | int resuming; |
846 | #endif | ||
847 | }; | 847 | }; |
848 | 848 | ||
849 | /** | 849 | /** |
@@ -854,7 +854,7 @@ struct MHD_Connection | |||
854 | * @param con connection handle | 854 | * @param con connection handle |
855 | * @return new closure | 855 | * @return new closure |
856 | */ | 856 | */ |
857 | typedef void * (*LogCallback)(void * cls, | 857 | typedef void * (*LogCallback)(void * cls, |
858 | const char * uri, | 858 | const char * uri, |
859 | struct MHD_Connection *con); | 859 | struct MHD_Connection *con); |
860 | 860 | ||
@@ -1088,7 +1088,7 @@ struct MHD_Daemon | |||
1088 | int epoll_fd; | 1088 | int epoll_fd; |
1089 | 1089 | ||
1090 | /** | 1090 | /** |
1091 | * MHD_YES if the listen socket is in the 'epoll' set, | 1091 | * MHD_YES if the listen socket is in the 'epoll' set, |
1092 | * MHD_NO if not. | 1092 | * MHD_NO if not. |
1093 | */ | 1093 | */ |
1094 | int listen_socket_in_epoll; | 1094 | int listen_socket_in_epoll; |