aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd/digestauth.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/microhttpd/digestauth.c')
-rw-r--r--src/microhttpd/digestauth.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/microhttpd/digestauth.c b/src/microhttpd/digestauth.c
index af146c31..1eea4446 100644
--- a/src/microhttpd/digestauth.c
+++ b/src/microhttpd/digestauth.c
@@ -59,6 +59,8 @@
59 */ 59 */
60#define MAX_DIGEST SHA256_DIGEST_SIZE 60#define MAX_DIGEST SHA256_DIGEST_SIZE
61 61
62#define MAX_NONCE NONCE_STD_LEN((MAX_DIGEST)+1)
63
62/** 64/**
63 * Macro to avoid using VLAs if the compiler does not support them. 65 * Macro to avoid using VLAs if the compiler does not support them.
64 */ 66 */
@@ -69,6 +71,13 @@
69 * @param n length of the digest to be used for a VLA 71 * @param n length of the digest to be used for a VLA
70 */ 72 */
71#define VLA_ARRAY_LEN_DIGEST(n) (((n) <= MAX_DIGEST?1:(mhd_panic(mhd_panic_cls, __FILE__, __LINE__, "VLA too big"),1)),MAX_DIGEST) 73#define VLA_ARRAY_LEN_DIGEST(n) (((n) <= MAX_DIGEST?1:(mhd_panic(mhd_panic_cls, __FILE__, __LINE__, "VLA too big"),1)),MAX_DIGEST)
74
75/**
76 * Check that @a n is below #MAX_NONCE, then return #MAX_NONCE.
77 *
78 * @param n length of the digest to be used for a VLA
79 */
80#define VLA_ARRAY_LEN_NONCE(n) (((n) <= MAX_NONCE?1:(mhd_panic(mhd_panic_cls, __FILE__, __LINE__, "VLA too big"),1)),MAX_NONCE)
72#else 81#else
73/** 82/**
74 * Check that @a n is below #MAX_DIGEST, then return @a n. 83 * Check that @a n is below #MAX_DIGEST, then return @a n.
@@ -76,6 +85,13 @@
76 * @param n length of the digest to be used for a VLA 85 * @param n length of the digest to be used for a VLA
77 */ 86 */
78#define VLA_ARRAY_LEN_DIGEST(n) (((n) <= MAX_DIGEST?1:(mhd_panic(mhd_panic_cls, __FILE__, __LINE__, "VLA too big"),1)),n) 87#define VLA_ARRAY_LEN_DIGEST(n) (((n) <= MAX_DIGEST?1:(mhd_panic(mhd_panic_cls, __FILE__, __LINE__, "VLA too big"),1)),n)
88
89/**
90 * Check that @a n is below #MAX_NONCE, then return @a n.
91 *
92 * @param n length of the digest to be used for a VLA
93 */
94#define VLA_ARRAY_LEN_NONCE(n) (((n) <= MAX_NONCE?1:(mhd_panic(mhd_panic_cls, __FILE__, __LINE__, "VLA too big"),1)),n)
79#endif 95#endif
80 96
81/** 97/**
@@ -1320,7 +1336,7 @@ MHD_queue_auth_fail_response2 (struct MHD_Connection *connection,
1320 SETUP_DA (algo, da); 1336 SETUP_DA (algo, da);
1321 1337
1322 { 1338 {
1323 char nonce[NONCE_STD_LEN(da.digest_size) + 1]; 1339 char nonce[VLA_ARRAY_LEN_NONCE (NONCE_STD_LEN(da.digest_size) + 1)];
1324 /* Generating the server nonce */ 1340 /* Generating the server nonce */
1325 calculate_nonce ((uint32_t) MHD_monotonic_sec_counter(), 1341 calculate_nonce ((uint32_t) MHD_monotonic_sec_counter(),
1326 connection->method, 1342 connection->method,