commit 7ea8a3310e44d1ee3f455c3c1a1c630ca54057b3
parent 273a6df932af73d7c84fef8668a53b2e65311e24
Author: Christian Grothoff <christian@grothoff.org>
Date: Wed, 12 Dec 2018 01:21:05 +0100
avoid c99-style comments in examples, fix missed VLA
Diffstat:
3 files changed, 26 insertions(+), 8 deletions(-)
diff --git a/src/examples/suspend_resume_epoll.c b/src/examples/suspend_resume_epoll.c
@@ -74,7 +74,7 @@ ahc_echo (void *cls,
if (-1 != req->timerfd)
{
- // send response (echo request url)
+ /* send response (echo request url) */
response = MHD_create_response_from_buffer (strlen (url),
(void *) url,
MHD_RESPMEM_MUST_COPY);
@@ -86,7 +86,7 @@ ahc_echo (void *cls,
MHD_destroy_response (response);
return ret;
}
- // create timer and suspend connection
+ /* create timer and suspend connection */
req->timerfd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK);
if (-1 == req->timerfd)
{
@@ -183,24 +183,24 @@ main (int argc,
{
if (events_list[0].data.ptr)
{
- // A timer has timed out
+ /* A timer has timed out */
req = events_list[0].data.ptr;
- // read from the fd so the system knows we heard the notice
+ /* read from the fd so the system knows we heard the notice */
if (-1 == read(req->timerfd, &timer_expirations, sizeof(timer_expirations)))
{
return 1;
}
- // Now resume the connection
+ /* Now resume the connection */
MHD_resume_connection(req->connection);
}
}
else if (0 == current_event_count)
{
- // no events: continue
+ /* no events: continue */
}
else
{
- // error
+ /* error */
return 1;
}
if (! MHD_run(d))
diff --git a/src/microhttpd/digestauth.c b/src/microhttpd/digestauth.c
@@ -59,6 +59,8 @@
*/
#define MAX_DIGEST SHA256_DIGEST_SIZE
+#define MAX_NONCE NONCE_STD_LEN((MAX_DIGEST)+1)
+
/**
* Macro to avoid using VLAs if the compiler does not support them.
*/
@@ -69,6 +71,13 @@
* @param n length of the digest to be used for a VLA
*/
#define VLA_ARRAY_LEN_DIGEST(n) (((n) <= MAX_DIGEST?1:(mhd_panic(mhd_panic_cls, __FILE__, __LINE__, "VLA too big"),1)),MAX_DIGEST)
+
+/**
+ * Check that @a n is below #MAX_NONCE, then return #MAX_NONCE.
+ *
+ * @param n length of the digest to be used for a VLA
+ */
+#define VLA_ARRAY_LEN_NONCE(n) (((n) <= MAX_NONCE?1:(mhd_panic(mhd_panic_cls, __FILE__, __LINE__, "VLA too big"),1)),MAX_NONCE)
#else
/**
* Check that @a n is below #MAX_DIGEST, then return @a n.
@@ -76,6 +85,13 @@
* @param n length of the digest to be used for a VLA
*/
#define VLA_ARRAY_LEN_DIGEST(n) (((n) <= MAX_DIGEST?1:(mhd_panic(mhd_panic_cls, __FILE__, __LINE__, "VLA too big"),1)),n)
+
+/**
+ * Check that @a n is below #MAX_NONCE, then return @a n.
+ *
+ * @param n length of the digest to be used for a VLA
+ */
+#define VLA_ARRAY_LEN_NONCE(n) (((n) <= MAX_NONCE?1:(mhd_panic(mhd_panic_cls, __FILE__, __LINE__, "VLA too big"),1)),n)
#endif
/**
@@ -1320,7 +1336,7 @@ MHD_queue_auth_fail_response2 (struct MHD_Connection *connection,
SETUP_DA (algo, da);
{
- char nonce[NONCE_STD_LEN(da.digest_size) + 1];
+ char nonce[VLA_ARRAY_LEN_NONCE (NONCE_STD_LEN(da.digest_size) + 1)];
/* Generating the server nonce */
calculate_nonce ((uint32_t) MHD_monotonic_sec_counter(),
connection->method,
diff --git a/w32/common/MHD_config.h b/w32/common/MHD_config.h
@@ -10,7 +10,9 @@
#define MSVC 1
/* Define that MS VC does not support VLAs */
+#ifndef __clang__
#define __STDC_NO_VLA__ 1
+#endif
/* Define to 1 if your C compiler supports inline functions. */
#define INLINE_FUNC 1