libmicrohttpd

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

commit 63b63330fbe75873dce0e4e820da75de295ffd51
parent 1a7e4a5a5be438726de9e9c9a55e23c021b62d47
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Thu, 27 Jan 2022 20:31:05 +0300

Updated doxy; explicitly tolerated NULL in MHD_queue*_auth*()

Diffstat:
Msrc/include/microhttpd.h | 10+++++-----
Msrc/microhttpd/basicauth.c | 7+++++--
Msrc/microhttpd/connection.c | 4++--
Msrc/microhttpd/digestauth.c | 7++++++-
4 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h @@ -3226,8 +3226,8 @@ MHD_lookup_connection_value_n (struct MHD_Connection *connection, * * @param connection the connection identifying the client * @param status_code HTTP status code (i.e. #MHD_HTTP_OK) - * @param response response to transmit - * @return #MHD_NO on error (i.e. reply already sent), + * @param response response to transmit, the NULL is tolerated + * @return #MHD_NO on error (reply already sent, response is NULL), * #MHD_YES on success or if message has been queued * @ingroup response * @sa #MHD_AccessHandlerCallback @@ -4226,7 +4226,7 @@ MHD_digest_auth_check_digest (struct MHD_Connection *connection, * @param opaque string to user for opaque value * @param response reply to send; should contain the "access denied" * body; note that this function will set the "WWW Authenticate" - * header and that the caller should not do this + * header and that the caller should not do this; the NULL is tolerated * @param signal_stale #MHD_YES if the nonce is invalid to add * 'stale=true' to the authentication header * @param algo digest algorithm to use @@ -4253,7 +4253,7 @@ MHD_queue_auth_fail_response2 (struct MHD_Connection *connection, * @param opaque string to user for opaque value * @param response reply to send; should contain the "access denied" * body; note that this function will set the "WWW Authenticate" - * header and that the caller should not do this + * header and that the caller should not do this; the NULL is tolerated * @param signal_stale #MHD_YES if the nonce is invalid to add * 'stale=true' to the authentication header * @return #MHD_YES on success, #MHD_NO otherwise @@ -4290,7 +4290,7 @@ MHD_basic_auth_get_username_password (struct MHD_Connection *connection, * * @param connection The MHD connection structure * @param realm the realm presented to the client - * @param response response object to modify and queue + * @param response response object to modify and queue; the NULL is tolerated * @return #MHD_YES on success, #MHD_NO otherwise * @ingroup authentication */ diff --git a/src/microhttpd/basicauth.c b/src/microhttpd/basicauth.c @@ -109,14 +109,14 @@ MHD_basic_auth_get_username_password (struct MHD_Connection *connection, /** - * Queues a response to request basic authentication from the client. + * Queues a response to request basic authentication from the client * The given response object is expected to include the payload for * the response; the "WWW-Authenticate" header will be added and the * response queued with the 'UNAUTHORIZED' status code. * * @param connection The MHD connection structure * @param realm the realm presented to the client - * @param response response object to modify and queue + * @param response response object to modify and queue; the NULL is tolerated * @return #MHD_YES on success, #MHD_NO otherwise * @ingroup authentication */ @@ -130,6 +130,9 @@ MHD_queue_basic_auth_fail_response (struct MHD_Connection *connection, size_t hlen = strlen (realm) + strlen ("Basic realm=\"\"") + 1; char *header; + if (NULL == response) + return MHD_NO; + header = (char *) malloc (hlen); if (NULL == header) { diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c @@ -5084,8 +5084,8 @@ MHD_set_connection_option (struct MHD_Connection *connection, * * @param connection the connection identifying the client * @param status_code HTTP status code (i.e. #MHD_HTTP_OK) - * @param response response to transmit - * @return #MHD_NO on error (i.e. reply already sent), + * @param response response to transmit, the NULL is tolerated + * @return #MHD_NO on error (reply already sent, response is NULL), * #MHD_YES on success or if message has been queued * @ingroup response * @sa #MHD_AccessHandlerCallback diff --git a/src/microhttpd/digestauth.c b/src/microhttpd/digestauth.c @@ -1326,11 +1326,12 @@ MHD_digest_auth_check_digest (struct MHD_Connection *connection, * @param opaque string to user for opaque value * @param response reply to send; should contain the "access denied" * body; note that this function will set the "WWW Authenticate" - * header and that the caller should not do this + * header and that the caller should not do this; the NULL is tolerated * @param signal_stale #MHD_YES if the nonce is invalid to add * 'stale=true' to the authentication header * @param algo digest algorithm to use * @return #MHD_YES on success, #MHD_NO otherwise + * @note Available since #MHD_VERSION 0x00096200 * @ingroup authentication */ enum MHD_Result @@ -1345,6 +1346,10 @@ MHD_queue_auth_fail_response2 (struct MHD_Connection *connection, int hlen; SETUP_DA (algo, da); + if (NULL == response) + return MHD_NO; + + if (1) { char nonce[NONCE_STD_LEN (VLA_ARRAY_LEN_DIGEST (da.digest_size)) + 1];