gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [libmicrohttpd] branch master updated (8d9065a0 -> 11fc9224


From: gnunet
Subject: [GNUnet-SVN] [libmicrohttpd] branch master updated (8d9065a0 -> 11fc9224)
Date: Sat, 25 Mar 2017 21:00:55 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a change to branch master
in repository libmicrohttpd.

    from 8d9065a0 MHD_start_daemon(): check for invalid combination of 
MHD_USE_NO_LISTEN_SOCKET and MHD_OPTION_LISTEN_SOCKET
     new bf7418b3 fix #4967
     new b8e94081 do not fail if MHD_OPTION_THREAD_POOL_SIZE is specified as 0 
or 1 in combination with internal polling, that's OK (as a pool size of 0/1 
means no pool)
     new 11fc9224 remove dead code converting hex number to size_t

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 ChangeLog                     |   9 +
 src/microhttpd/connection.c   |  44 ++-
 src/microhttpd/daemon.c       |  39 +--
 src/microhttpd/internal.h     |   4 +-
 src/microhttpd/mhd_str.c      |  89 ------
 src/microhttpd/mhd_str.h      |  32 ---
 src/microhttpd/test_str.c     | 644 ------------------------------------------
 src/microhttpd/test_upgrade.c |  16 +-
 8 files changed, 69 insertions(+), 808 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 08dd8499..4f627234 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Sat Mar 25 20:58:24 CET 2017
+       Remove dead MHD_strx_to_sizet-functions and associated
+       test cases from code. -CG
+
+Sat Mar 25 20:40:10 CET 2017
+       Allow chunk size > 16 MB (up to 2^64-1). Ignore
+       chunk extensions instead of triggering an error.
+       (fixes #4967). -CG
+
 Tue Mar 25 20:59:18 MSK 2017
        Check for invalid combinations of flags and options in
        MHD_start_daemon(). -EG
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 61023295..8ebc90db 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -1852,10 +1852,11 @@ call_connection_handler (struct MHD_Connection 
*connection)
 static void
 process_request_body (struct MHD_Connection *connection)
 {
-  size_t processed;
+  uint64_t processed;
   size_t available;
   size_t used;
   size_t i;
+  size_t end_size;
   int instant_retry;
   int malformed;
   char *buffer_head;
@@ -1872,7 +1873,7 @@ process_request_body (struct MHD_Connection *connection)
            (MHD_SIZE_UNKNOWN == connection->remaining_upload_size) )
         {
           if ( (connection->current_chunk_offset == 
connection->current_chunk_size) &&
-               (0 != connection->current_chunk_offset) &&
+               (0LLU != connection->current_chunk_offset) &&
                (available >= 2) )
             {
               /* skip new line at the *end* of a chunk */
@@ -1915,28 +1916,41 @@ process_request_body (struct MHD_Connection *connection)
               while (i < available)
                 {
                   if ( ('\r' == buffer_head[i]) ||
-                       ('\n' == buffer_head[i]) )
+                       ('\n' == buffer_head[i]) ||
+                      (';' == buffer_head[i]) )
                     break;
                   i++;
-                  if (i >= 6)
+                  if (i >= 16)
                     break;
                 }
-              /* take '\n' into account; if '\n'
-                 is the unavailable character, we
-                 will need to wait until we have it
+             end_size = i;
+             /* find beginning of CRLF (skip over chunk extensions) */
+             if (';' == buffer_head[i])
+               {
+                 while (i < available)
+                 {
+                   if ( ('\r' == buffer_head[i]) ||
+                        ('\n' == buffer_head[i]) )
+                     break;
+                   i++;
+                 }
+               }             
+              /* take '\n' into account; if '\n' is the unavailable
+                 character, we will need to wait until we have it
                  before going further */
               if ( (i + 1 >= available) &&
                    ! ( (1 == i) &&
                        (2 == available) &&
                        ('0' == buffer_head[0]) ) )
                 break;          /* need more data... */
-              malformed = (i >= 6);
+             i++;
+              malformed = (end_size >= 16);
               if (! malformed)
                 {
-                  size_t num_dig = MHD_strx_to_sizet_n_ (buffer_head,
-                                                         i,
-                                                         
&connection->current_chunk_size);
-                  malformed = (i != num_dig);
+                  size_t num_dig = MHD_strx_to_uint64_n_ (buffer_head,
+                                                         end_size,
+                                                         
&connection->current_chunk_size);
+                  malformed = (end_size != num_dig);
                 }
               if (malformed)
                 {
@@ -1945,11 +1959,11 @@ process_request_body (struct MHD_Connection *connection)
                                          _("Received malformed HTTP request 
(bad chunked encoding). Closing connection.\n"));
                   return;
                 }
-              i++;
+             /* skip 2nd part of line feed */
               if ( (i < available) &&
                    ( ('\r' == buffer_head[i]) ||
                      ('\n' == buffer_head[i]) ) )
-                i++;            /* skip 2nd part of line feed */
+                i++;            
 
               buffer_head += i;
               available -= i;
@@ -1957,7 +1971,7 @@ process_request_body (struct MHD_Connection *connection)
 
               if (available > 0)
                 instant_retry = MHD_YES;
-              if (0 == connection->current_chunk_size)
+              if (0LLU == connection->current_chunk_size)
                 {
                   connection->remaining_upload_size = 0;
                   break;
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index 69180865..f2427902 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -4822,24 +4822,6 @@ parse_options_va (struct MHD_Daemon *daemon,
                                                  void *);
           break;
         case MHD_OPTION_THREAD_POOL_SIZE:
-          if (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD))
-            {
-#ifdef HAVE_MESSAGES
-              MHD_DLOG (daemon,
-                        _("MHD_OPTION_THREAD_POOL_SIZE option is specified but 
"
-                          "MHD_USE_INTERNAL_POLLING_THREAD flag is not 
specified.\n"));
-#endif
-              return MHD_NO;
-            }
-          if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
-            {
-#ifdef HAVE_MESSAGES
-              MHD_DLOG (daemon,
-                        _("Both MHD_OPTION_THREAD_POOL_SIZE option and "
-                          "MHD_USE_THREAD_PER_CONNECTION flag are 
specified.\n"));
-#endif
-              return MHD_NO;
-            }
           daemon->worker_pool_size = va_arg (ap,
                                              unsigned int);
           if (0 == daemon->worker_pool_size)
@@ -4868,6 +4850,27 @@ parse_options_va (struct MHD_Daemon *daemon,
 #endif
              return MHD_NO;
            }
+         else
+           {
+             if (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD))
+               {
+#ifdef HAVE_MESSAGES
+                 MHD_DLOG (daemon,
+                           _("MHD_OPTION_THREAD_POOL_SIZE option is specified 
but "
+                             "MHD_USE_INTERNAL_POLLING_THREAD flag is not 
specified.\n"));
+#endif
+                 return MHD_NO;
+               }
+             if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
+               {
+#ifdef HAVE_MESSAGES
+                 MHD_DLOG (daemon,
+                           _("Both MHD_OPTION_THREAD_POOL_SIZE option and "
+                             "MHD_USE_THREAD_PER_CONNECTION flag are 
specified.\n"));
+#endif
+                 return MHD_NO;
+               }
+           }
           break;
 #ifdef HTTPS_SUPPORT
         case MHD_OPTION_HTTPS_MEM_KEY:
diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h
index 5350c013..1356e92e 100644
--- a/src/microhttpd/internal.h
+++ b/src/microhttpd/internal.h
@@ -863,13 +863,13 @@ struct MHD_Connection
    * otherwise, this is the size of the current chunk.  A value of
    * zero is also used when we're at the end of the chunks.
    */
-  size_t current_chunk_size;
+  uint64_t current_chunk_size;
 
   /**
    * If we are receiving with chunked encoding, where are we currently
    * with respect to the current chunk (at what offset / position)?
    */
-  size_t current_chunk_offset;
+  uint64_t current_chunk_offset;
 
   /**
    * Handler used for processing read connection operations
diff --git a/src/microhttpd/mhd_str.c b/src/microhttpd/mhd_str.c
index 3004c795..22db4e20 100644
--- a/src/microhttpd/mhd_str.c
+++ b/src/microhttpd/mhd_str.c
@@ -454,95 +454,6 @@ MHD_str_to_uint64_n_ (const char * str,
 
 
 /**
- * Convert hexadecimal US-ASCII digits in string to number in size_t.
- * Conversion stopped at first non-digit character.
- *
- * @param str string to convert
- * @param[out] out_val pointer to size_t to store result of conversion
- * @return non-zero number of characters processed on succeed,
- *         zero if no digit is found, resulting value is larger
- *         then possible to store in size_t or @a out_val is NULL
- */
-size_t
-MHD_strx_to_sizet_ (const char *str,
-                    size_t *out_val)
-{
-  const char * const start = str;
-  size_t res;
-  int digit;
-
-  if (!str || !out_val)
-    return 0;
-
-  res = 0;
-  digit = toxdigitvalue (*str);
-  while (digit >= 0)
-    {
-      if ( (res < (SIZE_MAX / 16)) ||
-           ( (res == (SIZE_MAX / 16)) &&
-             ((size_t)digit <= (SIZE_MAX % 16)) ) )
-        {
-          res *= 16;
-          res += digit;
-        }
-      else
-        return 0;
-      str++;
-      digit = toxdigitvalue (*str);
-    }
-
-  if (str - start > 0)
-    *out_val = res;
-  return str - start;
-}
-
-
-/**
- * Convert not more then @a maxlen hexadecimal US-ASCII digits in string
- * to number in size_t.
- * Conversion stopped at first non-digit character or after @a maxlen
- * digits.
- *
- * @param str string to convert
- * @param maxlen maximum number of characters to process
- * @param[out] out_val pointer to size_t to store result of conversion
- * @return non-zero number of characters processed on succeed,
- *         zero if no digit is found, resulting value is larger
- *         then possible to store in size_t or @a out_val is NULL
- */
-size_t
-MHD_strx_to_sizet_n_ (const char * str,
-                      size_t maxlen,
-                      size_t *out_val)
-{
-  size_t i;
-  size_t res;
-  int digit;
-  if (!str || !out_val)
-    return 0;
-
-  res = 0;
-  i = 0;
-  while ( (i < maxlen) &&
-          ((digit = toxdigitvalue (str[i])) >= 0) )
-    {
-      if ( (res > (SIZE_MAX / 16)) ||
-           ( (res == (SIZE_MAX / 16)) &&
-             ((size_t)digit > (SIZE_MAX % 16)) ) )
-        return 0;
-
-      res *= 16;
-      res += digit;
-      i++;
-    }
-
-  if (i)
-    *out_val = res;
-  return i;
-}
-
-
-/**
  * Convert hexadecimal US-ASCII digits in string to number in uint32_t.
  * Conversion stopped at first non-digit character.
  *
diff --git a/src/microhttpd/mhd_str.h b/src/microhttpd/mhd_str.h
index 880970ca..0ee41717 100644
--- a/src/microhttpd/mhd_str.h
+++ b/src/microhttpd/mhd_str.h
@@ -106,38 +106,6 @@ MHD_str_to_uint64_n_ (const char * str,
 
 
 /**
- * Convert hexadecimal US-ASCII digits in string to number in size_t.
- * Conversion stopped at first non-digit character.
- * @param str string to convert
- * @param out_val pointer to size_t to store result of conversion
- * @return non-zero number of characters processed on succeed, 
- *         zero if no digit is found, resulting value is larger
- *         then possible to store in size_t or @a out_val is NULL
- */
-size_t
-MHD_strx_to_sizet_ (const char * str,
-                    size_t * out_val);
-
-
-/**
- * Convert not more then @a maxlen hexadecimal US-ASCII digits in string
- * to number in size_t.
- * Conversion stopped at first non-digit character or after @a maxlen 
- * digits.
- * @param str string to convert
- * @param maxlen maximum number of characters to process
- * @param out_val pointer to size_t to store result of conversion
- * @return non-zero number of characters processed on succeed,
- *         zero if no digit is found, resulting value is larger
- *         then possible to store in size_t or @a out_val is NULL
- */
-size_t
-MHD_strx_to_sizet_n_ (const char * str,
-                      size_t maxlen,
-                      size_t * out_val);
-
-
-/**
  * Convert hexadecimal US-ASCII digits in string to number in uint32_t.
  * Conversion stopped at first non-digit character.
  * @param str string to convert
diff --git a/src/microhttpd/test_str.c b/src/microhttpd/test_str.c
index 3f921303..e8581c22 100644
--- a/src/microhttpd/test_str.c
+++ b/src/microhttpd/test_str.c
@@ -1496,523 +1496,6 @@ int check_str_to_uint64_n_no_val(void)
 }
 
 
-int check_strx_to_sizet_valid(void)
-{
-  size_t t_failed = 0;
-  size_t i, j;
-  static const size_t n_checks = sizeof(xdstrs_w_values) / 
sizeof(xdstrs_w_values[0]);
-  int c_failed[n_checks];
-
-  memset(c_failed, 0, sizeof(c_failed));
-
-  for(j = 0; j < locale_name_count; j++)
-    {
-      set_test_locale(j); /* setlocale() can be slow! */
-      for(i = 0; i < n_checks; i++)
-        {
-          size_t rv;
-          size_t rs;
-          const struct str_with_value * const t = xdstrs_w_values + i;
-
-#if SIZE_MAX != UINT64_MAX
-          if (t->val > SIZE_MAX)
-            continue; /* number is too high for this function */
-#endif /* SIZE_MAX != UINT64_MAX */
-
-          if (c_failed[i])
-            continue; /* skip already failed checks */
-
-          if (t->str.len < t->num_of_digt)
-            {
-              fprintf(stderr, "ERROR: xdstrs_w_values[%u] has wrong 
num_of_digt (%u): num_of_digt is expected"
-                              " to be less or equal to str.len (%u).\n",
-                              (unsigned int) i, (unsigned int) t->num_of_digt, 
(unsigned int) t->str.len);
-              return -1;
-            }
-          rv = 1458532; /* some random value */
-          rs = MHD_strx_to_sizet_(t->str.str, &rv);
-          if (rs != t->num_of_digt)
-            {
-              t_failed++;
-              c_failed[i] = !0;
-              fprintf(stderr, "FAILED: MHD_strx_to_sizet_(\"%s\", ->0x%" 
PRIX64 ") returned %" PRIuPTR ", while expecting %d."
-                      " Locale: %s\n", n_prnt(t->str.str), (uint64_t)rv, 
(intptr_t)rs, (int)t->num_of_digt, get_current_locale_str());
-            }
-          if (rv != t->val)
-            {
-              t_failed++;
-              c_failed[i] = !0;
-              fprintf(stderr, "FAILED: MHD_strx_to_sizet_(\"%s\", ->0x%" 
PRIX64 ") converted string to value 0x%" PRIX64 ","
-                      " while expecting result 0x%" PRIX64 ". Locale: %s\n", 
n_prnt(t->str.str), (uint64_t)rv, (uint64_t)rv,
-                      t->val, get_current_locale_str());
-            }
-          if (verbose > 1 && j == locale_name_count - 1 && !c_failed[i])
-            printf("PASSED: MHD_strx_to_sizet_(\"%s\", ->0x%" PRIX64 ") == %" 
PRIuPTR "\n",
-                   n_prnt(t->str.str), (uint64_t)rv, rs);
-        }
-    }
-  return t_failed;
-}
-
-
-int check_strx_to_sizet_all_chars(void)
-{
-  static const size_t n_checks = 256; /* from 0 to 255 */
-  int c_failed[n_checks];
-  size_t t_failed = 0;
-  size_t j;
-
-  memset(c_failed, 0, sizeof(c_failed));
-
-  for(j = 0; j < locale_name_count; j++)
-    {
-      unsigned int c;
-      size_t test_val;
-
-      set_test_locale(j); /* setlocale() can be slow! */
-      for(c = 0; c < n_checks; c++)
-        {
-          static const size_t rnd_val = 234234;
-          size_t rs;
-          if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') ||(c >= 'a' && 
c <= 'f'))
-            continue; /* skip xdigits */
-          for(test_val = 0; test_val <= rnd_val&& !c_failed[c]; test_val += 
rnd_val)
-            {
-              char test_str[] = "0123";
-              size_t rv = test_val;
-
-              test_str[0] = (char) (unsigned char)c; /* replace first char 
with non-digit char */
-              rs = MHD_strx_to_sizet_(test_str, &rv);
-              if (rs != 0)
-                {
-                  t_failed++;
-                  c_failed[c] = !0;
-                  fprintf(stderr, "FAILED: MHD_strx_to_sizet_(\"%s\", ->0x%" 
PRIX64 ") returned %" PRIuPTR ", while expecting zero."
-                                  " Locale: %s\n", n_prnt(test_str), 
(uint64_t)rv, (uintptr_t)rs, get_current_locale_str());
-                }
-              else if (rv != test_val)
-                {
-                  t_failed++;
-                  c_failed[c] = !0;
-                  fprintf(stderr, "FAILED: MHD_strx_to_sizet_(\"%s\", 
&ret_val) modified value of ret_val"
-                                  " (before call: 0x%" PRIX64 ", after call 
0x%" PRIX64 "). Locale: %s\n",
-                                  n_prnt(test_str), (uint64_t)test_val, 
(uint64_t)rv, get_current_locale_str());
-                }
-            }
-          if (verbose > 1 && j == locale_name_count - 1 && !c_failed[c])
-            {
-              char test_str[] = "0123";
-              test_str[0] = (char) (unsigned char)c; /* replace first char 
with non-digit char */
-
-              printf("PASSED: MHD_strx_to_sizet_(\"%s\", &ret_val) == 0, value 
of ret_val is unmodified\n",
-                     n_prnt(test_str));
-            }
-        }
-    }
-  return t_failed;
-}
-
-
-int check_strx_to_sizet_overflow(void)
-{
-  size_t t_failed = 0;
-  size_t i, j;
-  static const size_t n_checks1 = sizeof(strx_ovflw) / sizeof(strx_ovflw[0]);
-#if SIZE_MAX != UINT64_MAX
-  static const size_t n_checks = sizeof(strx_ovflw) / sizeof(strx_ovflw[0]) +
-                                 sizeof(xdstrs_w_values) / 
sizeof(xdstrs_w_values[0]);
-#else  /* SIZE_MAX == UINT64_MAX */
-  static const size_t n_checks = sizeof(strx_ovflw) / sizeof(strx_ovflw[0]);
-#endif /* SIZE_MAX == UINT64_MAX */
-  int c_failed[n_checks];
-
-  memset(c_failed, 0, sizeof(c_failed));
-
-  for(j = 0; j < locale_name_count; j++)
-    {
-      set_test_locale(j); /* setlocale() can be slow! */
-      for(i = 0; i < n_checks; i++)
-        {
-          size_t rs;
-          static const size_t rnd_val = 74218431;
-          size_t test_val;
-          const char * str;
-          if (i < n_checks1)
-            {
-              const struct str_with_len * const t = strx_ovflw + i;
-              str = t->str;
-            }
-#if SIZE_MAX != UINT64_MAX
-          else
-            {
-              const struct str_with_value * const t = xdstrs_w_values + (i - 
n_checks1);
-              if (t->val <= SIZE_MAX)
-                continue; /* check only strings that should overflow size_t */
-              str = t->str.str;
-            }
-#else  /* SIZE_MAX == UINT64_MAX */
-          else
-            continue; /* silent compiler warning */
-#endif /* SIZE_MAX == UINT64_MAX */
-
-
-          for(test_val = 0; test_val <= rnd_val && !c_failed[i]; test_val += 
rnd_val)
-            {
-              size_t rv = test_val;
-
-              rs = MHD_strx_to_sizet_(str, &rv);
-              if (rs != 0)
-                {
-                  t_failed++;
-                  c_failed[i] = !0;
-                  fprintf(stderr, "FAILED: MHD_strx_to_sizet_(\"%s\", ->0x%" 
PRIX64 ") returned %" PRIuPTR ", while expecting zero."
-                                  " Locale: %s\n", n_prnt(str), (uint64_t)rv, 
(uintptr_t)rs, get_current_locale_str());
-                }
-              else if (rv != test_val)
-                {
-                  t_failed++;
-                  c_failed[i] = !0;
-                  fprintf(stderr, "FAILED: MHD_strx_to_sizet_(\"%s\", 
&ret_val) modified value of ret_val"
-                                  " (before call: 0x%" PRIX64 ", after call 
0x%" PRIX64 "). Locale: %s\n",
-                                  n_prnt(str), (uint64_t)test_val, 
(uint64_t)rv, get_current_locale_str());
-                }
-            }
-          if (verbose > 1 && j == locale_name_count - 1 && !c_failed[i])
-            printf("PASSED: MHD_strx_to_sizet_(\"%s\", &ret_val) == 0, value 
of ret_val is unmodified\n",
-                   n_prnt(str));
-        }
-    }
-  return t_failed;
-}
-
-
-int check_strx_to_sizet_no_val(void)
-{
-  size_t t_failed = 0;
-  size_t i, j;
-  static const size_t n_checks = sizeof(str_no_num) / sizeof(str_no_num[0]);
-  int c_failed[n_checks];
-
-  memset(c_failed, 0, sizeof(c_failed));
-
-  for(j = 0; j < locale_name_count; j++)
-    {
-      set_test_locale(j); /* setlocale() can be slow! */
-      for(i = 0; i < n_checks; i++)
-        {
-          size_t rs;
-          const struct str_with_len * const t = str_no_num + i;
-          static const size_t rnd_val = 74218431;
-          size_t test_val;
-
-          for(test_val = 0; test_val <= rnd_val && !c_failed[i]; test_val += 
rnd_val)
-            {
-              size_t rv = test_val;
-
-              rs = MHD_strx_to_sizet_(t->str, &rv);
-              if (rs != 0)
-                {
-                  t_failed++;
-                  c_failed[i] = !0;
-                  fprintf(stderr, "FAILED: MHD_strx_to_sizet_(\"%s\", ->0x%" 
PRIX64 ") returned %" PRIuPTR ", while expecting zero."
-                                  " Locale: %s\n", n_prnt(t->str), 
(uint64_t)rv, (uintptr_t)rs, get_current_locale_str());
-                }
-              else if (rv != test_val)
-                {
-                  t_failed++;
-                  c_failed[i] = !0;
-                  fprintf(stderr, "FAILED: MHD_strx_to_sizet_(\"%s\", 
&ret_val) modified value of ret_val"
-                                  " (before call: 0x%" PRIX64 ", after call 
0x%" PRIX64 "). Locale: %s\n",
-                                  n_prnt(t->str), (uint64_t)test_val, 
(uint64_t)rv, get_current_locale_str());
-                }
-            }
-          if (verbose > 1 && j == locale_name_count - 1 && !c_failed[i])
-            printf("PASSED: MHD_strx_to_sizet_(\"%s\", &ret_val) == 0, value 
of ret_val is unmodified\n",
-                   n_prnt(t->str));
-        }
-    }
-  return t_failed;
-}
-
-
-int check_strx_to_sizet_n_valid(void)
-{
-  size_t t_failed = 0;
-  size_t i, j;
-  static const size_t n_checks = sizeof(xdstrs_w_values) / 
sizeof(xdstrs_w_values[0]);
-  int c_failed[n_checks];
-
-  memset(c_failed, 0, sizeof(c_failed));
-
-  for(j = 0; j < locale_name_count; j++)
-    {
-      set_test_locale(j); /* setlocale() can be slow! */
-      for(i = 0; i < n_checks; i++)
-        {
-          size_t rv = 2352932; /* some random value */
-          size_t rs = 0;
-          size_t len;
-          const struct str_with_value * const t = xdstrs_w_values + i;
-
-#if SIZE_MAX != UINT64_MAX
-          if (t->val > SIZE_MAX)
-            continue; /* number is too high for this function */
-#endif /* SIZE_MAX != UINT64_MAX */
-
-          if (t->str.len < t->num_of_digt)
-            {
-              fprintf(stderr, "ERROR: xdstrs_w_values[%u] has wrong 
num_of_digt (%u): num_of_digt is expected"
-                              " to be less or equal to str.len (%u).\n",
-                              (unsigned int) i, (unsigned int) t->num_of_digt, 
(unsigned int) t->str.len);
-              return -1;
-            }
-          for (len = t->num_of_digt; len <= t->str.len + 1 && !c_failed[i]; 
len++)
-            {
-              rs = MHD_strx_to_sizet_n_(t->str.str, len, &rv);
-              if (rs != t->num_of_digt)
-                {
-                  t_failed++;
-                  c_failed[i] = !0;
-                  fprintf(stderr, "FAILED: MHD_strx_to_sizet_n_(\"%s\", %" 
PRIuPTR ", ->0x%" PRIX64 ")"
-                          " returned %" PRIuPTR ", while expecting %d. Locale: 
%s\n",
-                          n_prnt(t->str.str), (intptr_t)len, (uint64_t)rv, 
(intptr_t)rs,
-                          (int)t->num_of_digt, get_current_locale_str());
-                }
-              if (rv != t->val)
-                {
-                  t_failed++;
-                  c_failed[i] = !0;
-                  fprintf(stderr, "FAILED: MHD_strx_to_sizet_n_(\"%s\", %" 
PRIuPTR ", ->0x%" PRIX64 ")"
-                          " converted string to value 0x%" PRIX64 ", while 
expecting result 0x%" PRIX64
-                          ". Locale: %s\n", n_prnt(t->str.str), (intptr_t)len, 
(uint64_t)rv, (uint64_t)rv,
-                          t->val, get_current_locale_str());
-                }
-            }
-          if (verbose > 1 && j == locale_name_count - 1 && !c_failed[i])
-            printf("PASSED: MHD_strx_to_sizet_n_(\"%s\", %" PRIuPTR "..%" 
PRIuPTR ", ->0x%" PRIX64 ")"
-                   " == %" PRIuPTR "\n", n_prnt(t->str.str), 
(intptr_t)t->num_of_digt,
-                   (intptr_t)t->str.len + 1, (uint64_t)rv, rs);
-        }
-    }
-  return t_failed;
-}
-
-
-int check_strx_to_sizet_n_all_chars(void)
-{
-  static const size_t n_checks = 256; /* from 0 to 255 */
-  int c_failed[n_checks];
-  size_t t_failed = 0;
-  size_t j;
-
-  memset(c_failed, 0, sizeof(c_failed));
-
-  for(j = 0; j < locale_name_count; j++)
-    {
-      unsigned int c;
-      size_t test_val;
-
-      set_test_locale(j); /* setlocale() can be slow! */
-      for(c = 0; c < n_checks; c++)
-        {
-          static const size_t rnd_val = 98372558;
-          size_t rs;
-          size_t len;
-
-          if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && 
c <= 'f'))
-            continue; /* skip xdigits */
-
-          for (len = 0; len <= 5; len++)
-            {
-              for(test_val = 0; test_val <= rnd_val&& !c_failed[c]; test_val 
+= rnd_val)
-                {
-                  char test_str[] = "0123";
-                  size_t rv = test_val;
-
-                  test_str[0] = (char) (unsigned char)c; /* replace first char 
with non-digit char */
-                  rs = MHD_strx_to_sizet_n_(test_str, len, &rv);
-                  if (rs != 0)
-                    {
-                      t_failed++;
-                      c_failed[c] = !0;
-                      fprintf(stderr, "FAILED: MHD_strx_to_sizet_n_(\"%s\", %" 
PRIuPTR ", ->0x%" PRIX64 ")"
-                              " returned %" PRIuPTR ", while expecting zero. 
Locale: %s\n",
-                              n_prnt(test_str), (uintptr_t)len, (uint64_t)rv, 
(uintptr_t)rs, get_current_locale_str());
-                    }
-                  else if (rv != test_val)
-                    {
-                      t_failed++;
-                      c_failed[c] = !0;
-                      fprintf(stderr, "FAILED: MHD_strx_to_sizet_n_(\"%s\", %" 
PRIuPTR ", &ret_val)"
-                              " modified value of ret_val (before call: 0x%" 
PRIX64 ", after call 0x%" PRIX64 ")."
-                              " Locale: %s\n",
-                              n_prnt(test_str), (uintptr_t)len, 
(uint64_t)test_val, (uint64_t)rv, get_current_locale_str());
-                    }
-                }
-            }
-          if (verbose > 1 && j == locale_name_count - 1 && !c_failed[c])
-            {
-              char test_str[] = "0123";
-              test_str[0] = (char) (unsigned char)c; /* replace first char 
with non-digit char */
-
-              printf("PASSED: MHD_strx_to_sizet_n_(\"%s\", 0..5, &ret_val) == 
0, value of ret_val is unmodified\n",
-                     n_prnt(test_str));
-            }
-        }
-    }
-  return t_failed;
-}
-
-
-int check_strx_to_sizet_n_overflow(void)
-{
-  size_t t_failed = 0;
-  size_t i, j;
-  static const size_t n_checks1 = sizeof(strx_ovflw) / sizeof(strx_ovflw[0]);
-#if SIZE_MAX != UINT64_MAX
-  static const size_t n_checks = sizeof(strx_ovflw) / sizeof(strx_ovflw[0]) +
-                                 sizeof(xdstrs_w_values) / 
sizeof(xdstrs_w_values[0]);
-#else  /* SIZE_MAX == UINT64_MAX */
-  static const size_t n_checks = sizeof(strx_ovflw) / sizeof(strx_ovflw[0]);
-#endif /* SIZE_MAX == UINT64_MAX */
-  int c_failed[n_checks];
-
-  memset(c_failed, 0, sizeof(c_failed));
-
-  for(j = 0; j < locale_name_count; j++)
-    {
-      set_test_locale(j); /* setlocale() can be slow! */
-      for(i = 0; i < n_checks; i++)
-        {
-          size_t rs;
-          static const size_t rnd_val = 4;
-          size_t len;
-          const char * str;
-          size_t min_len, max_len;
-          if (i < n_checks1)
-            {
-              const struct str_with_len * const t = strx_ovflw + i;
-              str = t->str;
-              min_len = t->len;
-              max_len = t->len + 1;
-            }
-#if SIZE_MAX != UINT64_MAX
-          else
-            {
-              const struct str_with_value * const t = xdstrs_w_values + (i - 
n_checks1);
-              if (t->val <= SIZE_MAX)
-                continue; /* check only strings that should overflow size_t */
-
-              if (t->str.len < t->num_of_digt)
-                {
-                  fprintf(stderr, "ERROR: xdstrs_w_values[%u] has wrong 
num_of_digt (%u): num_of_digt is expected"
-                                  " to be less or equal to str.len (%u).\n",
-                                  (unsigned int) (i - n_checks1), (unsigned 
int) t->num_of_digt,
-                                  (unsigned int) t->str.len);
-                  return -1;
-                }
-              str = t->str.str;
-              min_len = t->num_of_digt;
-              max_len = t->str.len + 1;
-            }
-#else  /* SIZE_MAX == UINT64_MAX */
-          else
-            continue; /* silent compiler warning */
-#endif /* SIZE_MAX == UINT64_MAX */
-
-          for (len = min_len; len <= max_len; len++)
-            {
-              size_t test_val;
-              for(test_val = 0; test_val <= rnd_val && !c_failed[i]; test_val 
+= rnd_val)
-                {
-                  size_t rv = test_val;
-
-                  rs = MHD_strx_to_sizet_n_(str, len, &rv);
-                  if (rs != 0)
-                    {
-                      t_failed++;
-                      c_failed[i] = !0;
-                      fprintf(stderr, "FAILED: MHD_strx_to_sizet_n_(\"%s\", %" 
PRIuPTR ", ->0x%" PRIX64 ")"
-                              " returned %" PRIuPTR ", while expecting zero. 
Locale: %s\n",
-                              n_prnt(str), (uintptr_t)len, (uint64_t)rv, 
(uintptr_t)rs, get_current_locale_str());
-                    }
-                  else if (rv != test_val)
-                    {
-                      t_failed++;
-                      c_failed[i] = !0;
-                      fprintf(stderr, "FAILED: MHD_strx_to_sizet_n_(\"%s\", %" 
PRIuPTR ", &ret_val)"
-                              " modified value of ret_val (before call: 0x%" 
PRIX64 ", after call 0x%" PRIX64 ")."
-                              " Locale: %s\n", n_prnt(str), (uintptr_t)len, 
(uint64_t)test_val, (uint64_t)rv,
-                              get_current_locale_str());
-                    }
-                }
-            }
-          if (verbose > 1 && j == locale_name_count - 1 && !c_failed[i])
-            printf("PASSED: MHD_strx_to_sizet_n_(\"%s\", %" PRIuPTR "..%" 
PRIuPTR ", &ret_val) == 0,"
-                   " value of ret_val is unmodified\n", n_prnt(str), 
(uintptr_t)min_len,
-                   (uintptr_t)max_len);
-        }
-    }
-  return t_failed;
-}
-
-
-int check_strx_to_sizet_n_no_val(void)
-{
-  size_t t_failed = 0;
-  size_t i, j;
-  static const size_t n_checks = sizeof(str_no_num) / sizeof(str_no_num[0]);
-  int c_failed[n_checks];
-
-  memset(c_failed, 0, sizeof(c_failed));
-
-  for(j = 0; j < locale_name_count; j++)
-    {
-      set_test_locale(j); /* setlocale() can be slow! */
-      for(i = 0; i < n_checks; i++)
-        {
-          size_t rs;
-          const struct str_with_len * const t = str_no_num + i;
-          static const size_t rnd_val = 3214314212;
-          size_t len;
-
-          for (len = 0; len <= t->len + 1; len++)
-            {
-              size_t test_val;
-              for(test_val = 0; test_val <= rnd_val && !c_failed[i]; test_val 
+= rnd_val)
-                {
-                  size_t rv = test_val;
-
-                  rs = MHD_strx_to_sizet_n_(t->str, len, &rv);
-                  if (rs != 0)
-                    {
-                      t_failed++;
-                      c_failed[i] = !0;
-                      fprintf(stderr, "FAILED: MHD_strx_to_sizet_n_(\"%s\", %" 
PRIuPTR ", ->0x%" PRIX64 ")"
-                              " returned %" PRIuPTR ", while expecting zero. 
Locale: %s\n",
-                              n_prnt(t->str), (uintptr_t)len, (uint64_t)rv, 
(uintptr_t)rs, get_current_locale_str());
-                    }
-                  else if (rv != test_val)
-                    {
-                      t_failed++;
-                      c_failed[i] = !0;
-                      fprintf(stderr, "FAILED: MHD_strx_to_sizet_n_(\"%s\", %" 
PRIuPTR ", &ret_val)"
-                              " modified value of ret_val (before call: 0x%" 
PRIX64 ", after call 0x%" PRIX64 ")."
-                              " Locale: %s\n", n_prnt(t->str), (uintptr_t)len, 
(uint64_t)test_val, (uint64_t)rv,
-                              get_current_locale_str());
-                    }
-                }
-            }
-          if (verbose > 1 && j == locale_name_count - 1 && !c_failed[i])
-            printf("PASSED: MHD_strx_to_sizet_n_(\"%s\", 0..%" PRIuPTR ", 
&ret_val) == 0,"
-                   " value of ret_val is unmodified\n", n_prnt(t->str),
-                   (uintptr_t)t->len + 1);
-        }
-    }
-  return t_failed;
-}
-
-
 int check_strx_to_uint32_valid(void)
 {
   size_t t_failed = 0;
@@ -2958,8 +2441,6 @@ int run_str_to_X_tests(void)
 {
   int str_to_uint64_fails = 0;
   int str_to_uint64_n_fails = 0;
-  int strx_to_sizet_fails = 0;
-  int strx_to_sizet_n_fails = 0;
   int strx_to_uint32_fails = 0;
   int strx_to_uint32_n_fails = 0;
   int strx_to_uint64_fails = 0;
@@ -3090,130 +2571,6 @@ int run_str_to_X_tests(void)
   else if (verbose > 0)
     printf("PASSED: function MHD_str_to_uint64_n_() successfully passed all 
checks.\n\n");
 
-  res = check_strx_to_sizet_valid();
-  if (res != 0)
-    {
-      if (res < 0)
-        {
-          fprintf(stderr, "ERROR: test internal error in 
check_strx_to_sizet_valid().\n");
-          return 99;
-        }
-      strx_to_sizet_fails += res;
-      fprintf(stderr, "FAILED: testcase check_strx_to_sizet_valid() 
failed.\n\n");
-    }
-  else if (verbose > 1)
-    printf("PASSED: testcase check_strx_to_sizet_valid() successfully 
passed.\n\n");
-
-  res = check_strx_to_sizet_all_chars();
-  if (res != 0)
-    {
-      if (res < 0)
-        {
-          fprintf(stderr, "ERROR: test internal error in 
check_strx_to_sizet_all_chars().\n");
-          return 99;
-        }
-      strx_to_sizet_fails += res;
-      fprintf(stderr, "FAILED: testcase check_strx_to_sizet_all_chars() 
failed.\n\n");
-    }
-  else if (verbose > 1)
-    printf("PASSED: testcase check_strx_to_sizet_all_chars() successfully 
passed.\n\n");
-
-  res = check_strx_to_sizet_overflow();
-  if (res != 0)
-    {
-      if (res < 0)
-        {
-          fprintf(stderr, "ERROR: test internal error in 
check_strx_to_sizet_overflow().\n");
-          return 99;
-        }
-      strx_to_sizet_fails += res;
-      fprintf(stderr, "FAILED: testcase check_strx_to_sizet_overflow() 
failed.\n\n");
-    }
-  else if (verbose > 1)
-    printf("PASSED: testcase check_strx_to_sizet_overflow() successfully 
passed.\n\n");
-
-  res = check_strx_to_sizet_no_val();
-  if (res != 0)
-    {
-      if (res < 0)
-        {
-          fprintf(stderr, "ERROR: test internal error in 
check_strx_to_sizet_no_val().\n");
-          return 99;
-        }
-      strx_to_sizet_fails += res;
-      fprintf(stderr, "FAILED: testcase check_strx_to_sizet_no_val() 
failed.\n\n");
-    }
-  else if (verbose > 1)
-    printf("PASSED: testcase check_strx_to_sizet_no_val() successfully 
passed.\n\n");
-
-  if (strx_to_sizet_fails)
-    fprintf(stderr, "FAILED: function MHD_strx_to_sizet_() failed %d 
time%s.\n\n",
-                    strx_to_sizet_fails, strx_to_sizet_fails == 1 ? "" : "s");
-  else if (verbose > 0)
-    printf("PASSED: function MHD_strx_to_sizet_() successfully passed all 
checks.\n\n");
-
-  res = check_strx_to_sizet_n_valid();
-  if (res != 0)
-    {
-      if (res < 0)
-        {
-          fprintf(stderr, "ERROR: test internal error in 
check_strx_to_sizet_n_valid().\n");
-          return 99;
-        }
-      strx_to_sizet_n_fails += res;
-      fprintf(stderr, "FAILED: testcase check_strx_to_sizet_n_valid() 
failed.\n\n");
-    }
-  else if (verbose > 1)
-    printf("PASSED: testcase check_strx_to_sizet_n_valid() successfully 
passed.\n\n");
-
-  res = check_strx_to_sizet_n_all_chars();
-  if (res != 0)
-    {
-      if (res < 0)
-        {
-          fprintf(stderr, "ERROR: test internal error in 
check_strx_to_sizet_n_all_chars().\n");
-          return 99;
-        }
-      strx_to_sizet_n_fails += res;
-      fprintf(stderr, "FAILED: testcase check_strx_to_sizet_n_all_chars() 
failed.\n\n");
-    }
-  else if (verbose > 1)
-    printf("PASSED: testcase check_strx_to_sizet_n_all_chars() successfully 
passed.\n\n");
-
-  res = check_strx_to_sizet_n_overflow();
-  if (res != 0)
-    {
-      if (res < 0)
-        {
-          fprintf(stderr, "ERROR: test internal error in 
check_strx_to_sizet_n_overflow().\n");
-          return 99;
-        }
-      strx_to_sizet_n_fails += res;
-      fprintf(stderr, "FAILED: testcase check_strx_to_sizet_n_overflow() 
failed.\n\n");
-    }
-  else if (verbose > 1)
-    printf("PASSED: testcase check_strx_to_sizet_n_overflow() successfully 
passed.\n\n");
-
-  res = check_strx_to_sizet_n_no_val();
-  if (res != 0)
-    {
-      if (res < 0)
-        {
-          fprintf(stderr, "ERROR: test internal error in 
check_strx_to_sizet_n_no_val().\n");
-          return 99;
-        }
-      strx_to_sizet_n_fails += res;
-      fprintf(stderr, "FAILED: testcase check_strx_to_sizet_n_no_val() 
failed.\n\n");
-    }
-  else if (verbose > 1)
-    printf("PASSED: testcase check_strx_to_sizet_n_no_val() successfully 
passed.\n\n");
-
-  if (strx_to_sizet_n_fails)
-    fprintf(stderr, "FAILED: function MHD_strx_to_sizet_n_() failed %d 
time%s.\n\n",
-                    strx_to_sizet_n_fails, strx_to_sizet_n_fails == 1 ? "" : 
"s");
-  else if (verbose > 0)
-    printf("PASSED: function MHD_strx_to_sizet_n_() successfully passed all 
checks.\n\n");
-
   res = check_strx_to_uint32_valid();
   if (res != 0)
     {
@@ -3463,7 +2820,6 @@ int run_str_to_X_tests(void)
     printf("PASSED: function MHD_strx_to_uint64_n_() successfully passed all 
checks.\n\n");
 
   if (str_to_uint64_fails || str_to_uint64_n_fails ||
-      strx_to_sizet_fails || strx_to_sizet_n_fails ||
       strx_to_uint32_fails || strx_to_uint32_n_fails ||
       strx_to_uint64_fails || strx_to_uint64_n_fails)
     {
diff --git a/src/microhttpd/test_upgrade.c b/src/microhttpd/test_upgrade.c
index fe72a70f..e96009c3 100644
--- a/src/microhttpd/test_upgrade.c
+++ b/src/microhttpd/test_upgrade.c
@@ -990,14 +990,14 @@ test_upgrade (int flags,
 
   if (!test_tls)
     d = MHD_start_daemon (flags | MHD_USE_ERROR_LOG | MHD_ALLOW_UPGRADE,
-                        1080,
-                        NULL, NULL,
-                        &ahc_upgrade, NULL,
-                        MHD_OPTION_URI_LOG_CALLBACK, &log_cb, NULL,
-                        MHD_OPTION_NOTIFY_COMPLETED, &notify_completed_cb, 
NULL,
-                        MHD_OPTION_NOTIFY_CONNECTION, &notify_connection_cb, 
NULL,
-                        MHD_OPTION_THREAD_POOL_SIZE, pool,
-                        MHD_OPTION_END);
+                         1080,
+                         NULL, NULL,
+                         &ahc_upgrade, NULL,
+                         MHD_OPTION_URI_LOG_CALLBACK, &log_cb, NULL,
+                         MHD_OPTION_NOTIFY_COMPLETED, &notify_completed_cb, 
NULL,
+                         MHD_OPTION_NOTIFY_CONNECTION, &notify_connection_cb, 
NULL,
+                         MHD_OPTION_THREAD_POOL_SIZE, pool,
+                         MHD_OPTION_END);
 #ifdef HTTPS_SUPPORT
   else
     d = MHD_start_daemon (flags | MHD_USE_ERROR_LOG | MHD_ALLOW_UPGRADE | 
MHD_USE_TLS,

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]