gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libmicrohttpd] 01/07: Modified public Digest Username struct to include


From: gnunet
Subject: [libmicrohttpd] 01/07: Modified public Digest Username struct to include the algorithm
Date: Sun, 04 Sep 2022 13:43:24 +0200

This is an automated email from the git hooks/post-receive script.

karlson2k pushed a commit to branch master
in repository libmicrohttpd.

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

    Modified public Digest Username struct to include the algorithm
---
 src/include/microhttpd.h        | 12 ++++++++++--
 src/microhttpd/digestauth.c     | 19 +++++++------------
 src/testcurl/test_digestauth2.c | 12 ++++++++++--
 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"
  * 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,10 +4911,18 @@ 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,
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,
  * 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
index e3c12d85..dc6c4cb4 100644
--- 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)

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]