libmicrohttpd

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

commit 2a9071b862d8f4647fe22770a0dacdf595ea72fb
parent e5d0b31486637a2955316e501d7b9f9f1209df63
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Fri, 26 Aug 2022 09:02:52 +0300

Modified public Digest Username struct to include the algorithm

Diffstat:
Msrc/include/microhttpd.h | 12++++++++++--
Msrc/microhttpd/digestauth.c | 19+++++++------------
Msrc/testcurl/test_digestauth2.c | 12++++++++++--
3 files changed, 27 insertions(+), 16 deletions(-)

diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h @@ -96,7 +96,7 @@ extern "C" * they are parsed as decimal numbers. * Example: 0x01093001 = 1.9.30-1. */ -#define MHD_VERSION 0x00097533 +#define MHD_VERSION 0x00097534 /* If generic headers don't work on your platform, include headers which define 'va_list', 'size_t', 'ssize_t', 'intptr_t', 'off_t', @@ -4911,11 +4911,19 @@ MHD_digest_auth_get_request_info3 (struct MHD_Connection *connection); * * Application may modify buffers as needed until #MHD_free() is called for * pointer to this structure - * @note Available since #MHD_VERSION 0x00097525 + * @note Available since #MHD_VERSION 0x00097534 */ struct MHD_DigestAuthUsernameInfo { /** + * The algorithm as defined by client. + * Set automatically to MD5 if not specified by client. + * @warning Do not be confused with #MHD_DigestAuthAlgorithm, + * which uses other values! + */ + enum MHD_DigestAuthAlgo3 algo3; + + /** * The type of username used by client. * The 'invalid' and 'missing' types are not used in this structure, * instead NULL is returned by #MHD_digest_auth_get_username3(). diff --git a/src/microhttpd/digestauth.c b/src/microhttpd/digestauth.c @@ -780,7 +780,7 @@ get_rq_extended_uname_copy_z (const char *uname_ext, size_t uname_ext_len, * Get copy of username used by the client. * @param params the Digest Authorization parameters * @param uname_type the type of username - * @param[out] unames the pointer to the structure to be filled + * @param[out] uname_info the pointer to the structure to be filled * @param buf the buffer to be used for usernames * @param buf_size the size of the @a buf * @return the size of the @a buf used by pointers in @a unames structure @@ -975,17 +975,11 @@ MHD_digest_auth_get_request_info3 (struct MHD_Connection *connection) if ( (MHD_DIGEST_AUTH_UNAME_TYPE_MISSING != uname_type) && (MHD_DIGEST_AUTH_UNAME_TYPE_INVALID != uname_type) ) - { - struct MHD_DigestAuthUsernameInfo uname_strct; - memset (&uname_strct, 0, sizeof(uname_strct)); - unif_buf_used += get_rq_uname (params, uname_type, &uname_strct, - unif_buf_ptr + unif_buf_used, - unif_buf_size - unif_buf_used); - info->uname_type = uname_strct.uname_type; - info->username = uname_strct.username; - info->username_len = uname_strct.username_len; - info->userhash_bin = uname_strct.userhash_bin; - } + unif_buf_used += + get_rq_uname (params, uname_type, + (struct MHD_DigestAuthUsernameInfo *) info, + unif_buf_ptr + unif_buf_used, + unif_buf_size - unif_buf_used); else info->uname_type = uname_type; @@ -1072,6 +1066,7 @@ MHD_digest_auth_get_username3 (struct MHD_Connection *connection) return NULL; } mhd_assert (uname_type == uname_info->uname_type); + uname_info->algo3 = params->algo3; return uname_info; } diff --git a/src/testcurl/test_digestauth2.c b/src/testcurl/test_digestauth2.c @@ -550,11 +550,11 @@ ahc_echo (void *cls, } if (algo3 != dinfo->algo3) { - fprintf (stderr, "Unexpected 'algo'.\n" + fprintf (stderr, "Unexpected 'algo3'.\n" "Expected: %d\tRecieved: %d. ", (int) algo3, (int) dinfo->algo3); - mhdErrorExitDesc ("Wrong 'algo'"); + mhdErrorExitDesc ("Wrong 'algo3'"); } if (! test_rfc2069) { @@ -692,6 +692,14 @@ ahc_echo (void *cls, else if (NULL != uname->userhash_bin) mhdErrorExitDesc ("'userhash_bin' is NOT NULL"); } + if (algo3 != uname->algo3) + { + fprintf (stderr, "Unexpected 'algo3'.\n" + "Expected: %d\tRecieved: %d. ", + (int) algo3, + (int) uname->algo3); + mhdErrorExitDesc ("Wrong 'algo3'"); + } MHD_free (uname); if (! test_userdigest)