diff options
Diffstat (limited to 'src/microhttpd/connection.c')
-rw-r--r-- | src/microhttpd/connection.c | 13 |
1 files changed, 7 insertions, 6 deletions
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! */ |