[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libmicrohttpd] 13/14: digestauth: added support for extended notation f
From: |
gnunet |
Subject: |
[libmicrohttpd] 13/14: digestauth: added support for extended notation for old API |
Date: |
Thu, 21 Jul 2022 14:08:11 +0200 |
This is an automated email from the git hooks/post-receive script.
karlson2k pushed a commit to branch master
in repository libmicrohttpd.
commit aac0cc55ead7073d081576347ee92d88e262bc39
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Thu Jul 21 14:34:30 2022 +0300
digestauth: added support for extended notation for old API
---
src/microhttpd/digestauth.c | 44 ++++++++++++++++++++++++++------------------
1 file changed, 26 insertions(+), 18 deletions(-)
diff --git a/src/microhttpd/digestauth.c b/src/microhttpd/digestauth.c
index f4bf76c7..fe80bf0d 100644
--- a/src/microhttpd/digestauth.c
+++ b/src/microhttpd/digestauth.c
@@ -1200,35 +1200,43 @@ MHD_digest_auth_get_username (struct MHD_Connection
*connection)
{
const struct MHD_RqDAuth *params;
char *username;
- size_t username_len;
+ size_t buf_size;
+ enum MHD_DigestAuthUsernameType uname_type;
params = get_rq_dauth_params (connection);
if (NULL == params)
return NULL;
- if (NULL == params->username.value.str)
+ uname_type = get_rq_uname_type (params);
+
+ if ( (MHD_DIGEST_AUTH_UNAME_TYPE_STANDARD != uname_type) &&
+ (MHD_DIGEST_AUTH_UNAME_TYPE_EXTENDED != uname_type) )
return NULL;
- username_len = params->username.value.len;
- username = malloc (username_len + 1);
+ buf_size = get_rq_unames_size (params, uname_type);
+
+ mhd_assert (0 != buf_size);
+
+ username = (char *) MHD_calloc_ (1, buf_size);
if (NULL == username)
return NULL;
- if (! params->username.quoted)
- {
- /* The username is not quoted, no need to unquote */
- if (0 != username_len)
- memcpy (username, params->username.value.str, username_len);
- username[username_len] = 0; /* Zero-terminate */
- }
- else
+ if (1)
{
- /* Need to properly unquote the username */
- mhd_assert (0 != username_len); /* Quoted string may not be zero-legth */
- username_len = MHD_str_unquote (params->username.value.str, username_len,
- username);
- mhd_assert (0 != username_len); /* The unquoted string cannot be empty */
- username[username_len] = 0; /* Zero-terminate */
+ struct MHD_DigestAuthUsernameInfo uname_strct;
+ size_t used;
+
+ memset (&uname_strct, 0, sizeof(uname_strct));
+
+ used = get_rq_uname (params, uname_type, &uname_strct,
+ (uint8_t *) username, buf_size);
+ if (uname_type != uname_strct.uname_type)
+ { /* Broken encoding for extended notation */
+ free (username);
+ return NULL;
+ }
+ (void) used; /* Mute compiler warning for non-debug builds */
+ mhd_assert (buf_size >= used);
}
return username;
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [libmicrohttpd] 04/14: digestauth: simplified internal function call, (continued)
- [libmicrohttpd] 04/14: digestauth: simplified internal function call, gnunet, 2022/07/21
- [libmicrohttpd] 03/14: digestauth: added small helper function to simplify the code, gnunet, 2022/07/21
- [libmicrohttpd] 06/14: digest_auth_check(): removed one more large local variable, gnunet, 2022/07/21
- [libmicrohttpd] 07/14: digest calculations: further simplified code, removed some local variables, gnunet, 2022/07/21
- [libmicrohttpd] 08/14: digestauth: removed usage of variable-length arrays, gnunet, 2022/07/21
- [libmicrohttpd] 11/14: digestauth: fixed username extraction with the new API, gnunet, 2022/07/21
- [libmicrohttpd] 10/14: digest_auth_check(): updated the order of parameters check, gnunet, 2022/07/21
- [libmicrohttpd] 12/14: digestauth: do not allocate extra space for extended notation, gnunet, 2022/07/21
- [libmicrohttpd] 05/14: digestauth: added sanity check for digest macros, gnunet, 2022/07/21
- [libmicrohttpd] 09/14: digest_auth_check(): added support for username in extended notation, gnunet, 2022/07/21
- [libmicrohttpd] 13/14: digestauth: added support for extended notation for old API,
gnunet <=
- [libmicrohttpd] 14/14: Added test for Digest Auth with username in extended notation, gnunet, 2022/07/21