aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2022-08-26 09:02:52 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2022-08-26 09:42:13 +0300
commit2a9071b862d8f4647fe22770a0dacdf595ea72fb (patch)
treeecdd448f2894c27643d4315ce72755633599d2cc
parente5d0b31486637a2955316e501d7b9f9f1209df63 (diff)
downloadlibmicrohttpd-2a9071b862d8f4647fe22770a0dacdf595ea72fb.tar.gz
libmicrohttpd-2a9071b862d8f4647fe22770a0dacdf595ea72fb.zip
Modified public Digest Username struct to include the algorithm
-rw-r--r--src/include/microhttpd.h12
-rw-r--r--src/microhttpd/digestauth.c19
-rw-r--r--src/testcurl/test_digestauth2.c12
3 files changed, 27 insertions, 16 deletions
diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h
index 60edf6b7..1a23bc8b 100644
--- a/src/include/microhttpd.h
+++ b/src/include/microhttpd.h
@@ -96,7 +96,7 @@ extern "C"
96 * they are parsed as decimal numbers. 96 * they are parsed as decimal numbers.
97 * Example: 0x01093001 = 1.9.30-1. 97 * Example: 0x01093001 = 1.9.30-1.
98 */ 98 */
99#define MHD_VERSION 0x00097533 99#define MHD_VERSION 0x00097534
100 100
101/* If generic headers don't work on your platform, include headers 101/* If generic headers don't work on your platform, include headers
102 which define 'va_list', 'size_t', 'ssize_t', 'intptr_t', 'off_t', 102 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);
4911 * 4911 *
4912 * Application may modify buffers as needed until #MHD_free() is called for 4912 * Application may modify buffers as needed until #MHD_free() is called for
4913 * pointer to this structure 4913 * pointer to this structure
4914 * @note Available since #MHD_VERSION 0x00097525 4914 * @note Available since #MHD_VERSION 0x00097534
4915 */ 4915 */
4916struct MHD_DigestAuthUsernameInfo 4916struct MHD_DigestAuthUsernameInfo
4917{ 4917{
4918 /** 4918 /**
4919 * The algorithm as defined by client.
4920 * Set automatically to MD5 if not specified by client.
4921 * @warning Do not be confused with #MHD_DigestAuthAlgorithm,
4922 * which uses other values!
4923 */
4924 enum MHD_DigestAuthAlgo3 algo3;
4925
4926 /**
4919 * The type of username used by client. 4927 * The type of username used by client.
4920 * The 'invalid' and 'missing' types are not used in this structure, 4928 * The 'invalid' and 'missing' types are not used in this structure,
4921 * instead NULL is returned by #MHD_digest_auth_get_username3(). 4929 * instead NULL is returned by #MHD_digest_auth_get_username3().
diff --git a/src/microhttpd/digestauth.c b/src/microhttpd/digestauth.c
index cc6cd0ac..0a892e22 100644
--- 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,
780 * Get copy of username used by the client. 780 * Get copy of username used by the client.
781 * @param params the Digest Authorization parameters 781 * @param params the Digest Authorization parameters
782 * @param uname_type the type of username 782 * @param uname_type the type of username
783 * @param[out] unames the pointer to the structure to be filled 783 * @param[out] uname_info the pointer to the structure to be filled
784 * @param buf the buffer to be used for usernames 784 * @param buf the buffer to be used for usernames
785 * @param buf_size the size of the @a buf 785 * @param buf_size the size of the @a buf
786 * @return the size of the @a buf used by pointers in @a unames structure 786 * @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)
975 975
976 if ( (MHD_DIGEST_AUTH_UNAME_TYPE_MISSING != uname_type) && 976 if ( (MHD_DIGEST_AUTH_UNAME_TYPE_MISSING != uname_type) &&
977 (MHD_DIGEST_AUTH_UNAME_TYPE_INVALID != uname_type) ) 977 (MHD_DIGEST_AUTH_UNAME_TYPE_INVALID != uname_type) )
978 { 978 unif_buf_used +=
979 struct MHD_DigestAuthUsernameInfo uname_strct; 979 get_rq_uname (params, uname_type,
980 memset (&uname_strct, 0, sizeof(uname_strct)); 980 (struct MHD_DigestAuthUsernameInfo *) info,
981 unif_buf_used += get_rq_uname (params, uname_type, &uname_strct, 981 unif_buf_ptr + unif_buf_used,
982 unif_buf_ptr + unif_buf_used, 982 unif_buf_size - unif_buf_used);
983 unif_buf_size - unif_buf_used);
984 info->uname_type = uname_strct.uname_type;
985 info->username = uname_strct.username;
986 info->username_len = uname_strct.username_len;
987 info->userhash_bin = uname_strct.userhash_bin;
988 }
989 else 983 else
990 info->uname_type = uname_type; 984 info->uname_type = uname_type;
991 985
@@ -1072,6 +1066,7 @@ MHD_digest_auth_get_username3 (struct MHD_Connection *connection)
1072 return NULL; 1066 return NULL;
1073 } 1067 }
1074 mhd_assert (uname_type == uname_info->uname_type); 1068 mhd_assert (uname_type == uname_info->uname_type);
1069 uname_info->algo3 = params->algo3;
1075 1070
1076 return uname_info; 1071 return uname_info;
1077} 1072}
diff --git a/src/testcurl/test_digestauth2.c b/src/testcurl/test_digestauth2.c
index e3c12d85..dc6c4cb4 100644
--- a/src/testcurl/test_digestauth2.c
+++ b/src/testcurl/test_digestauth2.c
@@ -550,11 +550,11 @@ ahc_echo (void *cls,
550 } 550 }
551 if (algo3 != dinfo->algo3) 551 if (algo3 != dinfo->algo3)
552 { 552 {
553 fprintf (stderr, "Unexpected 'algo'.\n" 553 fprintf (stderr, "Unexpected 'algo3'.\n"
554 "Expected: %d\tRecieved: %d. ", 554 "Expected: %d\tRecieved: %d. ",
555 (int) algo3, 555 (int) algo3,
556 (int) dinfo->algo3); 556 (int) dinfo->algo3);
557 mhdErrorExitDesc ("Wrong 'algo'"); 557 mhdErrorExitDesc ("Wrong 'algo3'");
558 } 558 }
559 if (! test_rfc2069) 559 if (! test_rfc2069)
560 { 560 {
@@ -692,6 +692,14 @@ ahc_echo (void *cls,
692 else if (NULL != uname->userhash_bin) 692 else if (NULL != uname->userhash_bin)
693 mhdErrorExitDesc ("'userhash_bin' is NOT NULL"); 693 mhdErrorExitDesc ("'userhash_bin' is NOT NULL");
694 } 694 }
695 if (algo3 != uname->algo3)
696 {
697 fprintf (stderr, "Unexpected 'algo3'.\n"
698 "Expected: %d\tRecieved: %d. ",
699 (int) algo3,
700 (int) uname->algo3);
701 mhdErrorExitDesc ("Wrong 'algo3'");
702 }
695 MHD_free (uname); 703 MHD_free (uname);
696 704
697 if (! test_userdigest) 705 if (! test_userdigest)