[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libmicrohttpd] 32/36: Added macro for base64 decoded size
From: |
gnunet |
Subject: |
[libmicrohttpd] 32/36: Added macro for base64 decoded size |
Date: |
Thu, 01 Jun 2023 12:30:37 +0200 |
This is an automated email from the git hooks/post-receive script.
karlson2k pushed a commit to branch master
in repository libmicrohttpd.
commit fbd7cef55e809f9fc75206d3b358a8cd077222c0
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Thu May 25 20:06:12 2023 +0300
Added macro for base64 decoded size
---
src/microhttpd/basicauth.c | 2 +-
src/microhttpd/mhd_str.h | 10 ++++++++++
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/microhttpd/basicauth.c b/src/microhttpd/basicauth.c
index 07b124f1..78818a95 100644
--- a/src/microhttpd/basicauth.c
+++ b/src/microhttpd/basicauth.c
@@ -60,7 +60,7 @@ MHD_basic_auth_get_username_password3 (struct MHD_Connection
*connection)
if ((NULL == params->token68.str) || (0 == params->token68.len))
return NULL;
- decoded_max_len = (params->token68.len / 4) * 3;
+ decoded_max_len = MHD_base64_max_dec_size_ (params->token68.len);
ret = (struct MHD_BasicAuthInfo *) malloc (sizeof(struct MHD_BasicAuthInfo)
+ decoded_max_len + 1);
if (NULL != ret)
diff --git a/src/microhttpd/mhd_str.h b/src/microhttpd/mhd_str.h
index e2964406..f7a4f79f 100644
--- a/src/microhttpd/mhd_str.h
+++ b/src/microhttpd/mhd_str.h
@@ -739,6 +739,16 @@ MHD_str_quote (const char *unquoted,
#ifdef BAUTH_SUPPORT
+/**
+ * Returns the maximum possible size of the Base64 decoded data.
+ * The real recoded size could be up to two bytes smaller.
+ * @param enc_size the size of encoded data, in characters
+ * @return the maximum possible size of the decoded data, in bytes, if
+ * @a enc_size is valid (properly padded),
+ * undefined value smaller then @a enc_size if @a enc_size is not valid
+ */
+#define MHD_base64_max_dec_size_(enc_size) (((enc_size) / 4) * 3)
+
/**
* Convert Base64 encoded string to binary data.
* @param base64 the input string with Base64 encoded data, could be NOT zero
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [libmicrohttpd] 25/36: Detect sysctl() symbols in configure, (continued)
- [libmicrohttpd] 25/36: Detect sysctl() symbols in configure, gnunet, 2023/06/01
- [libmicrohttpd] 28/36: contrib/make-dist.sh: added use of zopfli if available, gnunet, 2023/06/01
- [libmicrohttpd] 29/36: daemon.c: redesigned code for clarity and formatting, gnunet, 2023/06/01
- [libmicrohttpd] 35/36: autoinit_funcs.h: fixed warning on MSVC, gnunet, 2023/06/01
- [libmicrohttpd] 27/36: Added support for custom command for tarball compression, gnunet, 2023/06/01
- [libmicrohttpd] 15/36: examples/largepost.c: fixed caseless method match, gnunet, 2023/06/01
- [libmicrohttpd] 20/36: tests: unified use of function name macros, gnunet, 2023/06/01
- [libmicrohttpd] 21/36: Added internal preprocessor macro for magic macro presence, gnunet, 2023/06/01
- [libmicrohttpd] 30/36: Fixed compiler warning when built without poll() support, gnunet, 2023/06/01
- [libmicrohttpd] 31/36: Avoided potential compiler warnings, gnunet, 2023/06/01
- [libmicrohttpd] 32/36: Added macro for base64 decoded size,
gnunet <=
- [libmicrohttpd] 36/36: W32 VS Project: fixed warning with external build systems, gnunet, 2023/06/01
- [libmicrohttpd] 34/36: W32 VS Project: minor internal fixes, fixed files for "dist", gnunet, 2023/06/01
- [libmicrohttpd] 33/36: W32 VS project: reverted to standard arches names, gnunet, 2023/06/01