[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libmicrohttpd] branch master updated (65dac757 -> 523fa712)
From: |
gnunet |
Subject: |
[libmicrohttpd] branch master updated (65dac757 -> 523fa712) |
Date: |
Mon, 19 Apr 2021 15:26:04 +0200 |
This is an automated email from the git hooks/post-receive script.
karlson2k pushed a change to branch master
in repository libmicrohttpd.
from 65dac757 testzzuf/test_put_chunked: fixed callback
new 69c600bd mhd_send: added TLS-specific error code
new 0b22e203 log messaged-related minor fixes
new 523fa712 connection: report error details for recv() as well
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
src/microhttpd/connection.c | 63 +++++++++++++++++++++++++--------------
src/microhttpd/connection.h | 5 ++++
src/microhttpd/connection_https.c | 23 ++++++++++++--
src/microhttpd/daemon.c | 17 ++++++-----
src/microhttpd/mhd_send.c | 12 ++++++--
5 files changed, 86 insertions(+), 34 deletions(-)
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index baf0fcb4..916e75c8 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -152,6 +152,8 @@ str_conn_error_ (ssize_t mhd_err_code)
return _ ("Argument value is not supported");
case MHD_ERR_PIPE_:
return _ ("The socket is no longer available for sending");
+ case MHD_ERR_TLS_:
+ return _ ("TLS encryption or decryption error");
default:
break; /* Mute compiler warning */
}
@@ -206,9 +208,19 @@ recv_param_adapter (struct MHD_Connection *connection,
}
if (MHD_SCKT_ERR_IS_EINTR_ (err))
return MHD_ERR_AGAIN_;
- if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_ECONNRESET_))
+ if (MHD_SCKT_ERR_IS_REMOTE_DISCNN_ (err))
return MHD_ERR_CONNRESET_;
- /* Treat any other error as hard error. */
+ if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_EOPNOTSUPP_))
+ return MHD_ERR_OPNOTSUPP_;
+ if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_ENOTCONN_))
+ return MHD_ERR_NOTCONN_;
+ if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_EINVAL_))
+ return MHD_ERR_INVAL_;
+ if (MHD_SCKT_ERR_IS_LOW_RESOURCES_ (err))
+ return MHD_ERR_NOMEM_;
+ if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_EBADF_))
+ return MHD_ERR_BADF_;
+ /* Treat any other error as a hard error. */
return MHD_ERR_NOTCONN_;
}
#ifdef EPOLL_SUPPORT
@@ -796,6 +808,7 @@ connection_close_error (struct MHD_Connection *connection,
#ifdef HAVE_MESSAGES
if (NULL != emsg)
MHD_DLOG (connection->daemon,
+ "%s\n",
emsg);
#else /* ! HAVE_MESSAGES */
(void) emsg; /* Mute compiler warning. */
@@ -853,7 +866,7 @@ try_ready_normal_body (struct MHD_Connection *connection)
MHD_mutex_unlock_chk_ (&response->mutex);
/* not enough memory */
CONNECTION_CLOSE_ERROR (connection,
- _ ("Closing connection (out of memory).\n"));
+ _ ("Closing connection (out of memory)."));
return MHD_NO;
}
memcpy (connection->resp_iov.iov,
@@ -898,7 +911,7 @@ try_ready_normal_body (struct MHD_Connection *connection)
else
CONNECTION_CLOSE_ERROR (connection,
_ (
- "Closing connection (application reported
error generating data).\n"));
+ "Closing connection (application reported
error generating data)."));
return MHD_NO;
}
response->data_start = connection->response_write_position;
@@ -947,7 +960,7 @@ try_ready_chunked_body (struct MHD_Connection *connection)
#endif
/* not enough memory */
CONNECTION_CLOSE_ERROR (connection,
- _ ("Closing connection (out of memory).\n"));
+ _ ("Closing connection (out of memory)."));
return MHD_NO;
}
if ( (2 * (0xFFFFFF + sizeof(cbuf) + 2)) < size)
@@ -995,7 +1008,7 @@ try_ready_chunked_body (struct MHD_Connection *connection)
#endif
CONNECTION_CLOSE_ERROR (connection,
_ (
- "Closing connection (application error
generating response).\n"));
+ "Closing connection (application error
generating response)."));
return MHD_NO;
}
if ( (((ssize_t) MHD_CONTENT_READER_END_OF_STREAM) == ret) ||
@@ -1665,7 +1678,7 @@ transmit_error_response (struct MHD_Connection
*connection,
/* can't even send a reply, at least close the connection */
CONNECTION_CLOSE_ERROR (connection,
_ (
- "Closing connection (failed to queue
response).\n"));
+ "Closing connection (failed to queue
response)."));
return;
}
mhd_assert (NULL != connection->response);
@@ -1676,7 +1689,7 @@ transmit_error_response (struct MHD_Connection
*connection,
/* oops - close! */
CONNECTION_CLOSE_ERROR (connection,
_ (
- "Closing connection (failed to create response
header).\n"));
+ "Closing connection (failed to create response
header)."));
}
else
{
@@ -2218,7 +2231,7 @@ call_connection_handler (struct MHD_Connection
*connection)
/* serious internal error, close connection */
CONNECTION_CLOSE_ERROR (connection,
_ (
- "Application reported internal error, closing
connection.\n"));
+ "Application reported internal error, closing
connection."));
return;
}
}
@@ -2287,7 +2300,7 @@ process_request_body (struct MHD_Connection *connection)
/* malformed encoding */
CONNECTION_CLOSE_ERROR (connection,
_ (
- "Received malformed HTTP request (bad
chunked encoding). Closing connection.\n"));
+ "Received malformed HTTP request (bad
chunked encoding). Closing connection."));
return;
}
available -= i;
@@ -2366,7 +2379,7 @@ process_request_body (struct MHD_Connection *connection)
/* malformed encoding */
CONNECTION_CLOSE_ERROR (connection,
_ (
- "Received malformed HTTP request (bad
chunked encoding). Closing connection.\n"));
+ "Received malformed HTTP request (bad
chunked encoding). Closing connection."));
return;
}
/* skip 2nd part of line feed */
@@ -2422,7 +2435,7 @@ process_request_body (struct MHD_Connection *connection)
/* serious internal error, close connection */
CONNECTION_CLOSE_ERROR (connection,
_ (
- "Application reported internal error, closing
connection.\n"));
+ "Application reported internal error, closing
connection."));
return;
}
if (left_unprocessed > to_be_processed)
@@ -2520,7 +2533,7 @@ process_header_line (struct MHD_Connection *connection,
/* error in header line, die hard */
CONNECTION_CLOSE_ERROR (connection,
_ (
- "Received malformed line (no colon). Closing
connection.\n"));
+ "Received malformed line (no colon). Closing
connection."));
return MHD_NO;
}
if (-1 >= connection->daemon->strict_for_client)
@@ -2695,7 +2708,7 @@ parse_connection_headers (struct MHD_Connection
*connection)
/* can't even send a reply, at least close the connection */
CONNECTION_CLOSE_ERROR (connection,
_ (
- "Closing connection (failed to create
response).\n"));
+ "Closing connection (failed to create
response)."));
return;
}
iret = MHD_queue_response (connection,
@@ -2707,7 +2720,7 @@ parse_connection_headers (struct MHD_Connection
*connection)
/* can't even send a reply, at least close the connection */
CONNECTION_CLOSE_ERROR (connection,
_ (
- "Closing connection (failed to queue
response).\n"));
+ "Closing connection (failed to queue
response)."));
}
return;
}
@@ -2744,7 +2757,8 @@ parse_connection_headers (struct MHD_Connection
*connection)
connection->remaining_upload_size = 0;
#ifdef HAVE_MESSAGES
MHD_DLOG (connection->daemon,
- "Failed to parse `Content-Length' header. Closing
connection.\n");
+ _ (
+ "Failed to parse `Content-Length' header. Closing
connection.\n"));
#endif
CONNECTION_CLOSE_ERROR (connection,
NULL);
@@ -2845,14 +2859,19 @@ MHD_connection_handle_read (struct MHD_Connection
*connection)
(MHD_CONNECTION_INIT == connection->state) ?
NULL :
_ (
- "Socket disconnected while reading
request.\n"));
+ "Socket disconnected while reading request."));
return;
}
+
+#ifdef HAVE_MESSAGES
+ if (MHD_CONNECTION_INIT != connection->state)
+ MHD_DLOG (connection->daemon,
+ _ ("Connection socket is closed when reading " \
+ "request due to the error: %s\n"),
+ str_conn_error_ (bytes_read));
+#endif
CONNECTION_CLOSE_ERROR (connection,
- (MHD_CONNECTION_INIT == connection->state) ?
- NULL :
- _ (
- "Connection socket is closed due to error when
reading request.\n"));
+ NULL);
return;
}
@@ -3687,7 +3706,7 @@ MHD_connection_handle_idle (struct MHD_Connection
*connection)
/* oops - close! */
CONNECTION_CLOSE_ERROR (connection,
_ (
- "Closing connection (failed to create
response header).\n"));
+ "Closing connection (failed to create
response header)."));
continue;
}
if ( (! connection->have_chunked_upload) ||
diff --git a/src/microhttpd/connection.h b/src/microhttpd/connection.h
index f7d7b17a..b21029e6 100644
--- a/src/microhttpd/connection.h
+++ b/src/microhttpd/connection.h
@@ -71,6 +71,11 @@
*/
#define MHD_ERR_PIPE_ (-3080)
+/**
+ * General TLS encryption or decryption error
+ */
+#define MHD_ERR_TLS_ (-4097)
+
/**
* Set callbacks for this connection to those for HTTP.
diff --git a/src/microhttpd/connection_https.c
b/src/microhttpd/connection_https.c
index 3d4b0bdb..0060c59a 100644
--- a/src/microhttpd/connection_https.c
+++ b/src/microhttpd/connection_https.c
@@ -73,9 +73,28 @@ recv_tls_adapter (struct MHD_Connection *connection,
}
if (res < 0)
{
- /* Likely 'GNUTLS_E_INVALID_SESSION' (client communication
- disrupted); interpret as a hard error */
connection->tls_read_ready = false;
+ if ( (GNUTLS_E_DECRYPTION_FAILED == res) ||
+ (GNUTLS_E_INVALID_SESSION == res) ||
+ (GNUTLS_E_DECOMPRESSION_FAILED == res) ||
+ (GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER == res) ||
+ (GNUTLS_E_UNSUPPORTED_VERSION_PACKET == res) ||
+ (GNUTLS_E_UNEXPECTED_PACKET_LENGTH == res) ||
+ (GNUTLS_E_UNEXPECTED_PACKET == res) ||
+ (GNUTLS_E_UNEXPECTED_HANDSHAKE_PACKET == res) ||
+ (GNUTLS_E_EXPIRED == res) ||
+ (GNUTLS_E_REHANDSHAKE == res) )
+ return MHD_ERR_TLS_;
+ if ( (GNUTLS_E_PULL_ERROR == res) ||
+ (GNUTLS_E_INTERNAL_ERROR == res) ||
+ (GNUTLS_E_CRYPTODEV_IOCTL_ERROR == res) ||
+ (GNUTLS_E_CRYPTODEV_DEVICE_ERROR == res) )
+ return MHD_ERR_PIPE_;
+ if (GNUTLS_E_PREMATURE_TERMINATION == res)
+ return MHD_ERR_CONNRESET_;
+ if (GNUTLS_E_MEMORY_ERROR == res)
+ return MHD_ERR_NOMEM_;
+ /* Treat any other error as a hard error. */
return MHD_ERR_NOTCONN_;
}
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index b91278a9..8d721203 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -562,7 +562,7 @@ MHD_init_daemon_certificate (struct MHD_Daemon *daemon)
{
#ifdef HAVE_MESSAGES
MHD_DLOG (daemon,
- "Too long trust certificate.\n");
+ _ ("Too long trust certificate.\n"));
#endif
return -1;
}
@@ -574,7 +574,7 @@ MHD_init_daemon_certificate (struct MHD_Daemon *daemon)
{
#ifdef HAVE_MESSAGES
MHD_DLOG (daemon,
- "Bad trust certificate format.\n");
+ _ ("Bad trust certificate format.\n"));
#endif
return -1;
}
@@ -599,7 +599,7 @@ MHD_init_daemon_certificate (struct MHD_Daemon *daemon)
{
#ifdef HAVE_MESSAGES
MHD_DLOG (daemon,
- "Too long key or certificate.\n");
+ _ ("Too long key or certificate.\n"));
#endif
return -1;
}
@@ -634,7 +634,7 @@ MHD_init_daemon_certificate (struct MHD_Daemon *daemon)
#ifdef HAVE_MESSAGES
if (0 != ret)
MHD_DLOG (daemon,
- "GnuTLS failed to setup x509 certificate/key: %s\n",
+ _ ("GnuTLS failed to setup x509 certificate/key: %s\n"),
gnutls_strerror (ret));
#endif
return ret;
@@ -649,7 +649,7 @@ MHD_init_daemon_certificate (struct MHD_Daemon *daemon)
#endif
#ifdef HAVE_MESSAGES
MHD_DLOG (daemon,
- "You need to specify a certificate and key location.\n");
+ _ ("You need to specify a certificate and key location.\n"));
#endif
return -1;
}
@@ -2447,7 +2447,7 @@ new_connection_prepare_ (struct MHD_Daemon *daemon,
eno = errno;
#ifdef HAVE_MESSAGES
MHD_DLOG (daemon,
- "Error allocating memory: %s\n",
+ _ ("Error allocating memory: %s\n"),
MHD_strerror_ (errno));
#endif
MHD_socket_close_chk_ (client_socket);
@@ -2754,7 +2754,7 @@ new_connection_process_ (struct MHD_Daemon *daemon,
eno = errno;
#ifdef HAVE_MESSAGES
MHD_DLOG (daemon,
- "Failed to create a thread: %s\n",
+ _ ("Failed to create a thread: %s\n"),
MHD_strerror_ (eno));
#endif
goto cleanup;
@@ -5355,7 +5355,8 @@ MHD_quiesce_daemon (struct MHD_Daemon *daemon)
{
#ifdef HAVE_MESSAGES
MHD_DLOG (daemon,
- "Using MHD_quiesce_daemon in this mode requires MHD_USE_ITC.\n");
+ _ (
+ "Using MHD_quiesce_daemon in this mode requires
MHD_USE_ITC.\n"));
#endif
return MHD_INVALID_SOCKET;
}
diff --git a/src/microhttpd/mhd_send.c b/src/microhttpd/mhd_send.c
index 049034c9..a9f2b484 100644
--- a/src/microhttpd/mhd_send.c
+++ b/src/microhttpd/mhd_send.c
@@ -788,8 +788,16 @@ MHD_send_data_ (struct MHD_Connection *connection,
if (GNUTLS_E_INTERRUPTED == ret)
return MHD_ERR_AGAIN_;
if ( (GNUTLS_E_ENCRYPTION_FAILED == ret) ||
- (GNUTLS_E_INVALID_SESSION == ret) )
- return MHD_ERR_INVAL_;
+ (GNUTLS_E_INVALID_SESSION == ret) ||
+ (GNUTLS_E_COMPRESSION_FAILED == ret) ||
+ (GNUTLS_E_EXPIRED == ret) ||
+ (GNUTLS_E_HASH_FAILED == ret) )
+ return MHD_ERR_TLS_;
+ if ( (GNUTLS_E_PUSH_ERROR == ret) ||
+ (GNUTLS_E_INTERNAL_ERROR == ret) ||
+ (GNUTLS_E_CRYPTODEV_IOCTL_ERROR == ret) ||
+ (GNUTLS_E_CRYPTODEV_DEVICE_ERROR == ret) )
+ return MHD_ERR_PIPE_;
if (GNUTLS_E_PREMATURE_TERMINATION == ret)
return MHD_ERR_CONNRESET_;
if (GNUTLS_E_MEMORY_ERROR == ret)
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [libmicrohttpd] branch master updated (65dac757 -> 523fa712),
gnunet <=