diff options
author | Christian Grothoff <christian@grothoff.org> | 2018-12-12 01:21:05 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2018-12-12 01:21:05 +0100 |
commit | 7ea8a3310e44d1ee3f455c3c1a1c630ca54057b3 (patch) | |
tree | 0a6af2275edf2e1bbec72f651a589763232c6ce2 /src | |
parent | 273a6df932af73d7c84fef8668a53b2e65311e24 (diff) | |
download | libmicrohttpd-7ea8a3310e44d1ee3f455c3c1a1c630ca54057b3.tar.gz libmicrohttpd-7ea8a3310e44d1ee3f455c3c1a1c630ca54057b3.zip |
avoid c99-style comments in examples, fix missed VLA
Diffstat (limited to 'src')
-rw-r--r-- | src/examples/suspend_resume_epoll.c | 14 | ||||
-rw-r--r-- | src/microhttpd/digestauth.c | 18 |
2 files changed, 24 insertions, 8 deletions
diff --git a/src/examples/suspend_resume_epoll.c b/src/examples/suspend_resume_epoll.c index 0f9f66bf..903dcd81 100644 --- a/src/examples/suspend_resume_epoll.c +++ b/src/examples/suspend_resume_epoll.c | |||
@@ -74,7 +74,7 @@ ahc_echo (void *cls, | |||
74 | 74 | ||
75 | if (-1 != req->timerfd) | 75 | if (-1 != req->timerfd) |
76 | { | 76 | { |
77 | // send response (echo request url) | 77 | /* send response (echo request url) */ |
78 | response = MHD_create_response_from_buffer (strlen (url), | 78 | response = MHD_create_response_from_buffer (strlen (url), |
79 | (void *) url, | 79 | (void *) url, |
80 | MHD_RESPMEM_MUST_COPY); | 80 | MHD_RESPMEM_MUST_COPY); |
@@ -86,7 +86,7 @@ ahc_echo (void *cls, | |||
86 | MHD_destroy_response (response); | 86 | MHD_destroy_response (response); |
87 | return ret; | 87 | return ret; |
88 | } | 88 | } |
89 | // create timer and suspend connection | 89 | /* create timer and suspend connection */ |
90 | req->timerfd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK); | 90 | req->timerfd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK); |
91 | if (-1 == req->timerfd) | 91 | if (-1 == req->timerfd) |
92 | { | 92 | { |
@@ -183,24 +183,24 @@ main (int argc, | |||
183 | { | 183 | { |
184 | if (events_list[0].data.ptr) | 184 | if (events_list[0].data.ptr) |
185 | { | 185 | { |
186 | // A timer has timed out | 186 | /* A timer has timed out */ |
187 | req = events_list[0].data.ptr; | 187 | req = events_list[0].data.ptr; |
188 | // read from the fd so the system knows we heard the notice | 188 | /* read from the fd so the system knows we heard the notice */ |
189 | if (-1 == read(req->timerfd, &timer_expirations, sizeof(timer_expirations))) | 189 | if (-1 == read(req->timerfd, &timer_expirations, sizeof(timer_expirations))) |
190 | { | 190 | { |
191 | return 1; | 191 | return 1; |
192 | } | 192 | } |
193 | // Now resume the connection | 193 | /* Now resume the connection */ |
194 | MHD_resume_connection(req->connection); | 194 | MHD_resume_connection(req->connection); |
195 | } | 195 | } |
196 | } | 196 | } |
197 | else if (0 == current_event_count) | 197 | else if (0 == current_event_count) |
198 | { | 198 | { |
199 | // no events: continue | 199 | /* no events: continue */ |
200 | } | 200 | } |
201 | else | 201 | else |
202 | { | 202 | { |
203 | // error | 203 | /* error */ |
204 | return 1; | 204 | return 1; |
205 | } | 205 | } |
206 | if (! MHD_run(d)) | 206 | if (! MHD_run(d)) |
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, |