commit 8d5ebaec91133120088d829cfb58c02e869ccd8b
parent d9ebd051d2877ba108e369a3c040f29c849ec0e0
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date: Mon, 6 Jun 2022 19:11:06 +0300
gen_auth: simplified value assignment
Diffstat:
4 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/src/microhttpd/basicauth.h b/src/microhttpd/basicauth.h
@@ -37,7 +37,7 @@
struct MHD_RqBAuth
{
- struct _MHD_cstr_w_len token68;
+ struct _MHD_str_w_len token68;
};
#endif /* ! MHD_BASICAUTH_H */
diff --git a/src/microhttpd/digestauth.h b/src/microhttpd/digestauth.h
@@ -51,7 +51,7 @@
struct MHD_RqDAuthParam
{
- struct _MHD_cstr_w_len value;
+ struct _MHD_str_w_len value;
bool quoted;
};
diff --git a/src/microhttpd/gen_auth.c b/src/microhttpd/gen_auth.c
@@ -91,8 +91,8 @@ parse_bauth_params (const char *str,
else
{
/* No more data in the string, only single token68. */
- const struct _MHD_cstr_w_len tkn = { str + token68_start, token68_len};
- memcpy (&pbauth->token68, &tkn, sizeof(tkn));
+ pbauth->token68.str = str + token68_start;
+ pbauth->token68.len = token68_len;
}
}
return true;
@@ -251,11 +251,8 @@ parse_dauth_params (const char *str,
/* Have valid parameter name and value */
mhd_assert (! quoted || 0 != value_len);
- if (1)
- {
- const struct _MHD_cstr_w_len val = {str + value_start, value_len};
- memcpy (&aparam->param->value, &val, sizeof(val));
- }
+ aparam->param->value.str = str + value_start;
+ aparam->param->value.len = value_len;
aparam->param->quoted = quoted;
break; /* Found matching parameter name */
diff --git a/src/microhttpd/mhd_str.h b/src/microhttpd/mhd_str.h
@@ -64,6 +64,15 @@ struct _MHD_cstr_w_len
};
/**
+ * String with length
+ */
+struct _MHD_str_w_len
+{
+ const char *str;
+ size_t len;
+};
+
+/**
* Static string initialiser for struct _MHD_str_w_len
*/
#define _MHD_S_STR_W_LEN(str) { str, MHD_STATICSTR_LEN_(str) }