libmicrohttpd

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

commit b4f1e487de8a91186b3a29ea7949473fb911c240
parent 9496be92715b0970832af3bb37afaefed36cc03c
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Sun, 12 Dec 2021 13:35:12 +0300

Fixed compatibility with old GnuTLS versions

Diffstat:
Msrc/microhttpd/connection_https.c | 5+++++
Msrc/microhttpd/daemon.c | 3+++
Msrc/microhttpd/mhd_send.c | 5+++++
3 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/src/microhttpd/connection_https.c b/src/microhttpd/connection_https.c @@ -91,8 +91,13 @@ recv_tls_adapter (struct MHD_Connection *connection, (GNUTLS_E_CRYPTODEV_IOCTL_ERROR == res) || (GNUTLS_E_CRYPTODEV_DEVICE_ERROR == res) ) return MHD_ERR_PIPE_; +#if defined(GNUTLS_E_PREMATURE_TERMINATION) if (GNUTLS_E_PREMATURE_TERMINATION == res) return MHD_ERR_CONNRESET_; +#elif defined(GNUTLS_E_UNEXPECTED_PACKET_LENGTH) + if (GNUTLS_E_UNEXPECTED_PACKET_LENGTH == res) + return MHD_ERR_CONNRESET_; +#endif /* GNUTLS_E_UNEXPECTED_PACKET_LENGTH */ if (GNUTLS_E_MEMORY_ERROR == res) return MHD_ERR_NOMEM_; /* Treat any other error as a hard error. */ diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c @@ -2317,8 +2317,10 @@ psk_gnutls_adapter (gnutls_session_t session, { struct MHD_Connection *connection; struct MHD_Daemon *daemon; +#if GNUTLS_VERSION_MAJOR >= 3 void *app_psk; size_t app_psk_size; +#endif /* GNUTLS_VERSION_MAJOR >= 3 */ connection = gnutls_session_get_ptr (session); if (NULL == connection) @@ -2371,6 +2373,7 @@ psk_gnutls_adapter (gnutls_session_t session, free (app_psk); return 0; #else + (void) username; (void) key; /* Mute compiler warning */ #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("PSK not supported by this server.\n")); diff --git a/src/microhttpd/mhd_send.c b/src/microhttpd/mhd_send.c @@ -799,8 +799,13 @@ MHD_send_data_ (struct MHD_Connection *connection, (GNUTLS_E_CRYPTODEV_IOCTL_ERROR == ret) || (GNUTLS_E_CRYPTODEV_DEVICE_ERROR == ret) ) return MHD_ERR_PIPE_; +#if defined(GNUTLS_E_PREMATURE_TERMINATION) if (GNUTLS_E_PREMATURE_TERMINATION == ret) return MHD_ERR_CONNRESET_; +#elif defined(GNUTLS_E_UNEXPECTED_PACKET_LENGTH) + if (GNUTLS_E_UNEXPECTED_PACKET_LENGTH == ret) + return MHD_ERR_CONNRESET_; +#endif /* GNUTLS_E_UNEXPECTED_PACKET_LENGTH */ if (GNUTLS_E_MEMORY_ERROR == ret) return MHD_ERR_NOMEM_; if (ret < 0)