aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-01-18 20:56:34 +0000
committerChristian Grothoff <christian@grothoff.org>2016-01-18 20:56:34 +0000
commit2aa0b2234d89cd6fa98b60430e86a66fac4f2a3e (patch)
tree2e32615cff6752a13eb22003f096e3ec4e59ccef
parent91e76659458849a184f7862504943d9cc2012206 (diff)
downloadlibmicrohttpd-2aa0b2234d89cd6fa98b60430e86a66fac4f2a3e.tar.gz
libmicrohttpd-2aa0b2234d89cd6fa98b60430e86a66fac4f2a3e.zip
add redundant length check to make static checkers happy and to avoid trouble in the future
-rw-r--r--src/microhttpd/digestauth.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/microhttpd/digestauth.c b/src/microhttpd/digestauth.c
index 6984fc2e..8e38dc41 100644
--- a/src/microhttpd/digestauth.c
+++ b/src/microhttpd/digestauth.c
@@ -303,7 +303,7 @@ lookup_sub_value (char *dest,
303 * @param connection The MHD connection structure 303 * @param connection The MHD connection structure
304 * @param nonce A pointer that referenced a zero-terminated array of nonce 304 * @param nonce A pointer that referenced a zero-terminated array of nonce
305 * @param nc The nonce counter, zero to add the nonce to the array 305 * @param nc The nonce counter, zero to add the nonce to the array
306 * @return MHD_YES if successful, MHD_NO if invalid (or we have no NC array) 306 * @return #MHD_YES if successful, #MHD_NO if invalid (or we have no NC array)
307 */ 307 */
308static int 308static int
309check_nonce_nc (struct MHD_Connection *connection, 309check_nonce_nc (struct MHD_Connection *connection,
@@ -314,6 +314,11 @@ check_nonce_nc (struct MHD_Connection *connection,
314 uint32_t mod; 314 uint32_t mod;
315 const char *np; 315 const char *np;
316 316
317 if (MAX_NONCE_LENGTH <= strlen (nonce))
318 return MHD_NO; /* This should be impossible, but static analysis
319 tools have a hard time with it *and* this also
320 protects against unsafe modifications that may
321 happen in the future... */
317 mod = connection->daemon->nonce_nc_size; 322 mod = connection->daemon->nonce_nc_size;
318 if (0 == mod) 323 if (0 == mod)
319 return MHD_NO; /* no array! */ 324 return MHD_NO; /* no array! */
@@ -335,8 +340,8 @@ check_nonce_nc (struct MHD_Connection *connection,
335 (void) MHD_mutex_lock_ (&connection->daemon->nnc_lock); 340 (void) MHD_mutex_lock_ (&connection->daemon->nnc_lock);
336 if (0 == nc) 341 if (0 == nc)
337 { 342 {
338 strcpy(connection->daemon->nnc[off].nonce, 343 strcpy (connection->daemon->nnc[off].nonce,
339 nonce); 344 nonce);
340 connection->daemon->nnc[off].nc = 0; 345 connection->daemon->nnc[off].nc = 0;
341 (void) MHD_mutex_unlock_ (&connection->daemon->nnc_lock); 346 (void) MHD_mutex_unlock_ (&connection->daemon->nnc_lock);
342 return MHD_YES; 347 return MHD_YES;