gnunet-svn
[Top][All Lists]
Advanced

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

[libmicrohttpd] branch master updated (1e7ad301 -> 4dadf8ec)


From: gnunet
Subject: [libmicrohttpd] branch master updated (1e7ad301 -> 4dadf8ec)
Date: Thu, 22 Dec 2022 18:18:30 +0100

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

karlson2k pushed a change to branch master
in repository libmicrohttpd.

    from 1e7ad301 Refactored cookies parsing.
     new e60c63af Always close connection after reply if both Content-Length 
and chucked are used
     new 42be9415 connection.c: cosmetics
     new 5c3a61d6 Added new daemon option MHD_OPTION_CLIENT_DISCIPLINE_LV
     new 012ae6c1 Updated W32 resources file
     new 4dadf8ec Updated parsing of cookies, reject cookie completely if 
discipline is very strict

The 5 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:
 src/examples/connection_close.c          |   2 +-
 src/examples/minimal_example.c           |   1 -
 src/examples/minimal_example_empty.c     |   1 -
 src/examples/minimal_example_empty_tls.c |   2 +-
 src/include/microhttpd.h                 |  74 ++++++++++++---
 src/microhttpd/connection.c              |  49 ++++++----
 src/microhttpd/daemon.c                  |  32 +++++--
 src/microhttpd/internal.h                |   5 +-
 src/microhttpd/microhttpd_dll_res.rc.in  |   4 +
 src/testcurl/Makefile.am                 |  24 +++--
 src/testcurl/test_parse_cookies.c        | 157 +++++++++++++++++++++++--------
 11 files changed, 267 insertions(+), 84 deletions(-)

diff --git a/src/examples/connection_close.c b/src/examples/connection_close.c
index 8558eb46..de79d9f1 100644
--- a/src/examples/connection_close.c
+++ b/src/examples/connection_close.c
@@ -118,7 +118,7 @@ main (int argc, char *const *argv)
     MHD_OPTION_NOTIFY_COMPLETED, &request_completed, NULL,
     MHD_OPTION_NOTIFY_CONNECTION, &connection_completed, NULL,
     MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 120,
-    MHD_OPTION_STRICT_FOR_CLIENT, (int) 1,
+    MHD_OPTION_CLIENT_DISCIPLINE_LVL, (int) 1,
     MHD_OPTION_END);
   if (d == NULL)
     return 1;
diff --git a/src/examples/minimal_example.c b/src/examples/minimal_example.c
index f7a0e64c..f3fb1c88 100644
--- a/src/examples/minimal_example.c
+++ b/src/examples/minimal_example.c
@@ -105,7 +105,6 @@ main (int argc,
     (uint16_t) port,
     NULL, NULL, &ahc_echo, &data_for_handler,
     MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 120,
-    MHD_OPTION_STRICT_FOR_CLIENT, (int) 1,
     MHD_OPTION_END);
   if (d == NULL)
     return 1;
diff --git a/src/examples/minimal_example_empty.c 
b/src/examples/minimal_example_empty.c
index 3556d753..2c76654a 100644
--- a/src/examples/minimal_example_empty.c
+++ b/src/examples/minimal_example_empty.c
@@ -93,7 +93,6 @@ main (int argc,
     (uint16_t) port,
     NULL, NULL, &ahc_echo, NULL,
     MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 120,
-    MHD_OPTION_STRICT_FOR_CLIENT, (int) 1,
     MHD_OPTION_END);
   if (d == NULL)
     return 1;
diff --git a/src/examples/minimal_example_empty_tls.c 
b/src/examples/minimal_example_empty_tls.c
index 465f7492..d0a4d6ff 100644
--- a/src/examples/minimal_example_empty_tls.c
+++ b/src/examples/minimal_example_empty_tls.c
@@ -160,7 +160,7 @@ main (int argc,
     (uint16_t) port,
     NULL, NULL, &ahc_echo, NULL,
     MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 120,
-    MHD_OPTION_STRICT_FOR_CLIENT, (int) 1,
+    MHD_OPTION_CLIENT_DISCIPLINE_LVL, (int) 1,
     /* Optionally, the gnutls_load_file() can be used to
        load the key and the certificate from file. */
     MHD_OPTION_HTTPS_MEM_KEY, srv_signed_key_pem,
diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h
index b66f4b3d..93967c60 100644
--- a/src/include/microhttpd.h
+++ b/src/include/microhttpd.h
@@ -96,7 +96,7 @@ extern "C"
  * they are parsed as decimal numbers.
  * Example: 0x01093001 = 1.9.30-1.
  */
-#define MHD_VERSION 0x00097544
+#define MHD_VERSION 0x00097545
 
 /* If generic headers don't work on your platform, include headers
    which define 'va_list', 'size_t', 'ssize_t', 'intptr_t', 'off_t',
@@ -1291,12 +1291,14 @@ enum MHD_FLAG
    * as liberal as possible in what you accept" norm.  It is
    * recommended to turn this ON if you are testing clients against
    * MHD, and OFF in production.
+   * @sa #MHD_OPTION_CLIENT_DISCIPLINE_LVL
    */
   MHD_USE_PEDANTIC_CHECKS = 32,
 #if 0 /* Will be marked for real deprecation later. */
 #define MHD_USE_PEDANTIC_CHECKS \
   _MHD_DEPR_IN_MACRO ( \
-    "Flag MHD_USE_PEDANTIC_CHECKS is deprecated, use option 
MHD_OPTION_STRICT_FOR_CLIENT instead") \
+    "Flag MHD_USE_PEDANTIC_CHECKS is deprecated, " \
+    "use option MHD_OPTION_CLIENT_DISCIPLINE_LVL instead") \
   32
 #endif /* 0 */
 
@@ -1939,15 +1941,18 @@ enum MHD_OPTION
    * If set to 1 - be strict about the protocol.  Use -1 to be
    * as tolerant as possible.
    *
-   * Specifically, at the moment, at 1 this flag
-   * causes MHD to reject HTTP 1.1 connections without a "Host" header,
-   * and to disallow spaces in the URL or (at -1) in HTTP header key strings.
+   * The more flexible option #MHD_OPTION_CLIENT_DISCIPLINE_LVL is recommended
+   * instead of this option.
    *
-   * These are required by some versions of the standard, but of
-   * course in violation of the "be as liberal as possible in what you
-   * accept" norm.  It is recommended to set this to 1 if you are
-   * testing clients against MHD, and 0 in production.  This option
-   * should be followed by an `int` argument.
+   * The values mapping table:
+   * #MHD_OPTION_STRICT_FOR_CLIENT | #MHD_OPTION_CLIENT_DISCIPLINE_LVL
+   * -----------------------------:|:---------------------------------
+   * 1                             | 1
+   * 0                             | 0
+   * -1                            | -3
+   *
+   * This option should be followed by an `int` argument.
+   * @sa #MHD_OPTION_CLIENT_DISCIPLINE_LVL
    */
   MHD_OPTION_STRICT_FOR_CLIENT = 29,
 
@@ -2037,7 +2042,54 @@ enum MHD_OPTION
    * default priorities.
    * @note Available since #MHD_VERSION 0x00097542
    */
-  MHD_OPTION_HTTPS_PRIORITIES_APPEND = 37
+  MHD_OPTION_HTTPS_PRIORITIES_APPEND = 37,
+
+  /**
+   * Sets specified client discipline level (i.e. HTTP protocol parsing
+   * strictness level).
+   *
+   * The following basic values are supported:
+   *  0 - default MHD level, a balance between extra security and broader
+   *      compatibility, as allowed by RFCs for HTTP servers;
+   *  1 - more strict protocol interpretation, within the limits set by
+   *      RFCs for HTTP servers;
+   * -1 - more lenient protocol interpretation, within the limits set by
+   *      RFCs for HTTP servers.
+   * The following extended values could be used as well:
+   *  2 - stricter protocol interpretation, even stricter then allowed
+   *      by RFCs for HTTP servers, however it should be absolutely compatible
+   *      with clients following at least RFCs' "MUST" type of requirements
+   *      for HTTP clients;
+   *  3 - strictest protocol interpretation, even stricter then allowed
+   *      by RFCs for HTTP servers, however it should be absolutely compatible
+   *      with clients following RFCs' "SHOULD" and "MUST" types of 
requirements
+   *      for HTTP clients;
+   * -2 - more relaxed protocol interpretation, violating RFCs' "SHOULD" type
+   *      of requirements for HTTP servers;
+   * -3 - the most flexible protocol interpretation, beyond RFCs' "MUST" type 
of
+   *      requirements for HTTP server.
+   * Values higher than "3" or lower than "-3" are interpreted as "3" or "-3"
+   * respectively.
+   *
+   * Higher values are more secure, lower values are more compatible with
+   * various HTTP clients.
+   *
+   * The default value ("0") could be used in most cases.
+   * Value "1" is suitable for highly loaded public servers.
+   * Values "2" and "3" are generally recommended only for testing of HTTP
+   * clients against MHD.
+   * Value "2" may be used for security-centric application, however it is
+   * slight violation of RFCs' requirements.
+   * Negative values are not recommended for public servers.
+   * Values "-1" and "-2" could be used for servers in isolated environment.
+   * Value "-3" is not recommended unless it is absolutely necessary to
+   * communicate with some client(s) with badly broken HTTP implementation.
+   *
+   * This option should be followed by an `int` argument.
+   * @note Available since #MHD_VERSION 0x00097545
+   */
+  MHD_OPTION_CLIENT_DISCIPLINE_LVL = 38
+
 } _MHD_FIXED_ENUM;
 
 
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 16c5fb93..b983e7ed 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -2846,15 +2846,15 @@ parse_cookies_string (char *str,
   size_t i;
   bool non_strict;
   /* Skip extra whitespaces and empty cookies */
-  const bool allow_wsp_empty = (0 >= connection->daemon->strict_for_client);
+  const bool allow_wsp_empty = (0 >= connection->daemon->client_discipline);
   /* Allow whitespaces around '=' character */
-  const bool wsp_around_eq = (0 > connection->daemon->strict_for_client);
+  const bool wsp_around_eq = (-3 >= connection->daemon->client_discipline);
   /* Allow whitespaces in quoted cookie value */
-  const bool wsp_in_quoted = (0 >= connection->daemon->strict_for_client);
+  const bool wsp_in_quoted = (-2 >= connection->daemon->client_discipline);
   /* Allow tab as space after semicolon between cookies */
-  const bool tab_as_sp = (0 >= connection->daemon->strict_for_client);
+  const bool tab_as_sp = (0 >= connection->daemon->client_discipline);
   /* Allow no space after semicolon between cookies */
-  const bool allow_no_space = (0 >= connection->daemon->strict_for_client);
+  const bool allow_no_space = (0 >= connection->daemon->client_discipline);
 
   non_strict = false;
   i = 0;
@@ -3048,8 +3048,10 @@ parse_cookie_header (struct MHD_Connection *connection)
   char *cpy;
   size_t i;
   enum _MHD_ParseCookie parse_res;
-  const struct MHD_HTTP_Req_Header *const saved_tail =
+  struct MHD_HTTP_Req_Header *const saved_tail =
     connection->rq.headers_received_tail;
+  const bool allow_partially_correct_cookie =
+    (1 >= connection->daemon->client_discipline);
 
   if (MHD_NO ==
       MHD_lookup_connection_value_n (connection,
@@ -3097,9 +3099,22 @@ parse_cookie_header (struct MHD_Connection *connection)
   case MHD_PARSE_COOKIE_MALFORMED:
 #ifdef HAVE_MESSAGES
     if (saved_tail != connection->rq.headers_received_tail)
-      MHD_DLOG (connection->daemon,
-                _ ("The Cookie header has been only partially parsed as it "
-                   "contains malformed data.\n"));
+    {
+      if (allow_partially_correct_cookie)
+        MHD_DLOG (connection->daemon,
+                  _ ("The Cookie header has been only partially parsed as it "
+                     "contains malformed data.\n"));
+      else
+      {
+        /* Remove extracted values from partially broken cookie */
+        /* Memory remains allocated until the end of the request processing */
+        connection->rq.headers_received_tail = saved_tail;
+        saved_tail->next = NULL;
+        MHD_DLOG (connection->daemon,
+                  _ ("The Cookie header has been ignored as it contains "
+                     "malformed data.\n"));
+      }
+    }
     else
       MHD_DLOG (connection->daemon,
                 _ ("The Cookie header has malformed data.\n"));
@@ -3152,7 +3167,7 @@ parse_http_version (struct MHD_Connection *connection,
   /* String must start with 'HTTP/d.d', case-sensetive match.
    * See https://www.rfc-editor.org/rfc/rfc9112#name-http-version */
   if ((HTTP_VER_LEN != len) ||
-      ('H' != h[0] ) || ('T' != h[1]) || ('T' != h[2]) || ('P' != h[3]) ||
+      ('H' != h[0]) || ('T' != h[1]) || ('T' != h[2]) || ('P' != h[3]) ||
       ('/' != h[4])
       || ('.' != h[6]) ||
       (('0' > h[5]) || ('9' < h[5])) ||
@@ -3327,7 +3342,7 @@ parse_initial_message_line (struct MHD_Connection 
*connection,
       uri_len = line_len - (size_t) (uri - line);
     }
     /* check for spaces in URI if we are "strict" */
-    if ( (1 <= daemon->strict_for_client) &&
+    if ( (-2 < daemon->client_discipline) &&
          (NULL != memchr (uri,
                           ' ',
                           uri_len)) )
@@ -3752,7 +3767,7 @@ process_header_line (struct MHD_Connection *connection,
     /* error in header line, die hard */
     return MHD_NO;
   }
-  if (-1 >= connection->daemon->strict_for_client)
+  if (-3 < connection->daemon->client_discipline)
   {
     /* check for whitespace before colon, which is not allowed
  by RFC 7230 section 3.2.4; we count space ' ' and
@@ -3897,7 +3912,7 @@ parse_connection_headers (struct MHD_Connection 
*connection)
     return;
   }
 #endif /* COOKIE_SUPPORT */
-  if ( (1 <= connection->daemon->strict_for_client) &&
+  if ( (-3 < connection->daemon->client_discipline) &&
        (MHD_IS_HTTP_VER_1_1_COMPAT (connection->rq.http_ver)) &&
        (MHD_NO ==
         MHD_lookup_connection_value_n (connection,
@@ -3946,22 +3961,24 @@ parse_connection_headers (struct MHD_Connection 
*connection)
                                             NULL))
     {
       /* TODO: add individual settings */
-      if (1 <= connection->daemon->strict_for_client)
+      if (1 <= connection->daemon->client_discipline)
       {
         transmit_error_response_static (connection,
                                         MHD_HTTP_BAD_REQUEST,
                                         REQUEST_LENGTH_WITH_TR_ENCODING);
         return;
       }
-#ifdef HAVE_MESSAGES
       else
       {
+        /* Must close connection after reply to prevent potential attack */
+        connection->keepalive = MHD_CONN_MUST_CLOSE;
+#ifdef HAVE_MESSAGES
         MHD_DLOG (connection->daemon,
                   _ ("The 'Content-Length' request header is ignored "
                      "as chunked Transfer-Encoding is used "
                      "for this request.\n"));
-      }
 #endif /* HAVE_MESSAGES */
+      }
     }
     connection->rq.have_chunked_upload = true;
     connection->rq.remaining_upload_size = MHD_SIZE_UNKNOWN;
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index d854de31..746d9493 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -5729,7 +5729,7 @@ unescape_wrapper (void *cls,
   (void) cls; /* Mute compiler warning. */
 
   /* TODO: add individual parameter */
-  if (1 <= connection->daemon->strict_for_client)
+  if (0 <= connection->daemon->client_discipline)
     return MHD_str_pct_decode_in_place_strict_ (val);
 
   res = MHD_str_pct_decode_in_place_lenient_ (val, &broken);
@@ -6653,14 +6653,33 @@ parse_options_va (struct MHD_Daemon *daemon,
                                             unsigned int);
       break;
     case MHD_OPTION_STRICT_FOR_CLIENT:
-      daemon->strict_for_client = va_arg (ap, int);
+      daemon->client_discipline = va_arg (ap, int); /* Temporal assignment */
+      /* Map to correct value */
+      if (-1 >= daemon->client_discipline)
+        daemon->client_discipline = -3;
+      else if (1 <= daemon->client_discipline)
+        daemon->client_discipline = 1;
 #ifdef HAVE_MESSAGES
       if ( (0 != (daemon->options & MHD_USE_PEDANTIC_CHECKS)) &&
-           (1 != daemon->strict_for_client) )
+           (1 != daemon->client_discipline) )
       {
         MHD_DLOG (daemon,
                   _ ("Flag MHD_USE_PEDANTIC_CHECKS is ignored because "
-                     "another behavior is specified by 
MHD_OPTION_STRICT_CLIENT.\n"));
+                     "another behaviour is specified by "
+                     "MHD_OPTION_STRICT_CLIENT.\n"));
+      }
+#endif /* HAVE_MESSAGES */
+      break;
+    case MHD_OPTION_CLIENT_DISCIPLINE_LVL:
+      daemon->client_discipline = va_arg (ap, int);
+#ifdef HAVE_MESSAGES
+      if ( (0 != (daemon->options & MHD_USE_PEDANTIC_CHECKS)) &&
+           (1 != daemon->client_discipline) )
+      {
+        MHD_DLOG (daemon,
+                  _ ("Flag MHD_USE_PEDANTIC_CHECKS is ignored because "
+                     "another behaviour is specified by "
+                     "MHD_OPTION_CLIENT_DISCIPLINE_LVL.\n"));
       }
 #endif /* HAVE_MESSAGES */
       break;
@@ -6723,6 +6742,7 @@ parse_options_va (struct MHD_Daemon *daemon,
           break;
         /* all options taking 'int' */
         case MHD_OPTION_STRICT_FOR_CLIENT:
+        case MHD_OPTION_CLIENT_DISCIPLINE_LVL:
         case MHD_OPTION_SIGPIPE_HANDLED_BY_APP:
         case MHD_OPTION_TLS_NO_ALPN:
           if (MHD_NO == parse_options (daemon,
@@ -7102,8 +7122,8 @@ MHD_start_daemon_va (unsigned int flags,
   daemon->listening_address_reuse = 0;
   daemon->options = *pflags;
   pflags = &daemon->options;
-  daemon->strict_for_client = (0 != (*pflags & MHD_USE_PEDANTIC_CHECKS)) ? 1 :
-                              0;
+  daemon->client_discipline = (0 != (*pflags & MHD_USE_PEDANTIC_CHECKS)) ?
+                              1 : 0;
   daemon->port = port;
   daemon->apc = apc;
   daemon->apc_cls = apc_cls;
diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h
index 78481b21..9f5ed442 100644
--- a/src/microhttpd/internal.h
+++ b/src/microhttpd/internal.h
@@ -2104,9 +2104,10 @@ struct MHD_Daemon
   unsigned int per_ip_connection_limit;
 
   /**
-   * Be neutral (zero), strict (1) or permissive (-1) to client.
+   * The strictness level for parsing of incoming data.
+   * @see #MHD_OPTION_CLIENT_DISCIPLINE_LVL
    */
-  int strict_for_client;
+  int client_discipline;
 
   /**
    * True if SIGPIPE is blocked
diff --git a/src/microhttpd/microhttpd_dll_res.rc.in 
b/src/microhttpd/microhttpd_dll_res.rc.in
index c6db3f8e..f89c07ab 100644
--- a/src/microhttpd/microhttpd_dll_res.rc.in
+++ b/src/microhttpd/microhttpd_dll_res.rc.in
@@ -7,7 +7,11 @@ VS_VERSION_INFO VERSIONINFO
   FILEVERSION 
@PACKAGE_VERSION_MAJOR@,@PACKAGE_VERSION_MINOR@,@PACKAGE_VERSION_SUBMINOR@,0
   PRODUCTVERSION 
@PACKAGE_VERSION_MAJOR@,@PACKAGE_VERSION_MINOR@,@PACKAGE_VERSION_SUBMINOR@,0
   FILEFLAGSMASK  VS_FFI_FILEFLAGSMASK
+#if defined(_DEBUG)
+  FILEFLAGS      VS_FF_DEBUG
+#else
   FILEFLAGS      0
+#endif
   FILEOS         VOS_NT_WINDOWS32
   FILETYPE       VFT_DLL
   FILESUBTYPE    VFT2_UNKNOWN
diff --git a/src/testcurl/Makefile.am b/src/testcurl/Makefile.am
index 0d190f9d..74583ff6 100644
--- a/src/testcurl/Makefile.am
+++ b/src/testcurl/Makefile.am
@@ -144,9 +144,11 @@ check_PROGRAMS = \
 
 if ENABLE_COOKIE
 check_PROGRAMS += \
-  test_parse_cookies_strict_p1 \
-  test_parse_cookies_strict_zero \
-  test_parse_cookies_strict_n1
+  test_parse_cookies_discp_p2 \
+  test_parse_cookies_discp_p1 \
+  test_parse_cookies_discp_zero \
+  test_parse_cookies_discp_n2 \
+  test_parse_cookies_discp_n3
 endif
 
 if HEAVY_TESTS
@@ -468,14 +470,20 @@ test_post_SOURCES = \
 test_process_headers_SOURCES = \
   test_process_headers.c mhd_has_in_name.h
 
-test_parse_cookies_strict_zero_SOURCES = \
+test_parse_cookies_discp_zero_SOURCES = \
   test_parse_cookies.c mhd_has_in_name.h mhd_has_param.h
 
-test_parse_cookies_strict_p1_SOURCES = \
-  $(test_parse_cookies_strict_zero_SOURCES)
+test_parse_cookies_discp_p2_SOURCES = \
+  $(test_parse_cookies_discp_zero_SOURCES)
 
-test_parse_cookies_strict_n1_SOURCES = \
-  $(test_parse_cookies_strict_zero_SOURCES)
+test_parse_cookies_discp_p1_SOURCES = \
+  $(test_parse_cookies_discp_zero_SOURCES)
+
+test_parse_cookies_discp_n2_SOURCES = \
+  $(test_parse_cookies_discp_zero_SOURCES)
+
+test_parse_cookies_discp_n3_SOURCES = \
+  $(test_parse_cookies_discp_zero_SOURCES)
 
 test_process_arguments_SOURCES = \
   test_process_arguments.c mhd_has_in_name.h
diff --git a/src/testcurl/test_parse_cookies.c 
b/src/testcurl/test_parse_cookies.c
index 308b751e..a7c57611 100644
--- a/src/testcurl/test_parse_cookies.c
+++ b/src/testcurl/test_parse_cookies.c
@@ -237,10 +237,11 @@ struct strct_test_data
 {
   unsigned int line_num;
   const char *header_str;
-  unsigned int num_cookies_strict_p2; /* Reserved */
+  unsigned int num_cookies_strict_p2;
   unsigned int num_cookies_strict_p1;
   unsigned int num_cookies_strict_zero;
-  unsigned int num_cookies_strict_n1;
+  unsigned int num_cookies_strict_n2;
+  unsigned int num_cookies_strict_n3;
   struct strct_cookie cookies[5];
 };
 
@@ -252,6 +253,7 @@ static const struct strct_test_data test_data[] = {
     1,
     1,
     1,
+    1,
     {
       COOKIE_ ("name1", "value1"),
       COOKIE_NULL,
@@ -263,6 +265,7 @@ static const struct strct_test_data test_data[] = {
   {
     __LINE__,
     "name1=value1;",
+    0,
     1,
     1,
     1,
@@ -282,6 +285,7 @@ static const struct strct_test_data test_data[] = {
     1,
     1,
     1,
+    1,
     {
       COOKIE_ ("name1", "value1"),
       COOKIE_NULL,
@@ -297,6 +301,7 @@ static const struct strct_test_data test_data[] = {
     0,
     1,
     1,
+    1,
     {
       COOKIE_ ("name1", "value1"),
       COOKIE_NULL,
@@ -312,6 +317,7 @@ static const struct strct_test_data test_data[] = {
     0,
     1,
     1,
+    1,
     {
       COOKIE_ ("name1", "value1"),
       COOKIE_NULL,
@@ -327,6 +333,7 @@ static const struct strct_test_data test_data[] = {
     1,
     1,
     1,
+    1,
     {
       COOKIE_ ("name1", "value1"),
       COOKIE_NULL,
@@ -342,6 +349,7 @@ static const struct strct_test_data test_data[] = {
     0,
     1,
     1,
+    1,
     {
       COOKIE_ ("name1", "value1"),
       COOKIE_NULL,
@@ -357,6 +365,7 @@ static const struct strct_test_data test_data[] = {
     0,
     1,
     1,
+    1,
     {
       COOKIE_ ("name1", "value1"),
       COOKIE_NULL,
@@ -370,6 +379,7 @@ static const struct strct_test_data test_data[] = {
     "name2=\"value 2\"",
     0,
     0,
+    0,
     1,
     1,
     {
@@ -387,6 +397,7 @@ static const struct strct_test_data test_data[] = {
     1,
     2,
     2,
+    2,
     {
       COOKIE_ ("name1", "value1"),
       COOKIE_ ("name2", "value2"),
@@ -402,9 +413,10 @@ static const struct strct_test_data test_data[] = {
     2,
     2,
     2,
+    2,
     {
       COOKIE_ ("name1", "value1"),
-      COOKIE_ ("name1", "value1"),
+      COOKIE_ ("name1", "value1"), /* The second value is not checked actually 
*/
       COOKIE_NULL,
       COOKIE_NULL,
       COOKIE_NULL
@@ -417,6 +429,7 @@ static const struct strct_test_data test_data[] = {
     2,
     2,
     2,
+    2,
     {
       COOKIE_ ("name1", "value1"),
       COOKIE_ ("name2", "value2"),
@@ -427,7 +440,8 @@ static const struct strct_test_data test_data[] = {
   },
   {
     __LINE__,
-    "name1=value1; name2=value2",
+    "name1=value1; name2=value2    ",
+    2,
     2,
     2,
     2,
@@ -442,8 +456,9 @@ static const struct strct_test_data test_data[] = {
   },
   {
     __LINE__,
-    "name1=value1; name2=value2",
-    2,
+    "name1=value1;  name2=value2",
+    0,
+    1,
     2,
     2,
     2,
@@ -457,8 +472,9 @@ static const struct strct_test_data test_data[] = {
   },
   {
     __LINE__,
-    "name1=value1; name2=value2",
-    2,
+    "name1=value1;name2=value2",
+    0,
+    1,
     2,
     2,
     2,
@@ -472,8 +488,9 @@ static const struct strct_test_data test_data[] = {
   },
   {
     __LINE__,
-    "name1=value1; name2=value2",
-    2,
+    "name1=value1;\tname2=value2",
+    0,
+    1,
     2,
     2,
     2,
@@ -487,8 +504,9 @@ static const struct strct_test_data test_data[] = {
   },
   {
     __LINE__,
-    "name1=value1; name2=value2",
-    2,
+    "name1=value1 ; name2=value2",
+    0,
+    0,
     2,
     2,
     2,
@@ -502,7 +520,8 @@ static const struct strct_test_data test_data[] = {
   },
   {
     __LINE__,
-    "name1=value1; name2=value2",
+    "     name1=value1; name2=value2",
+    2,
     2,
     2,
     2,
@@ -522,6 +541,7 @@ static const struct strct_test_data test_data[] = {
     "name5=var_with_=_char",
     0,
     3,
+    3,
     5,
     5,
     {
@@ -539,6 +559,7 @@ static const struct strct_test_data test_data[] = {
     "name5=var_with_=_char",
     0,
     1,
+    3,
     5,
     5,
     {
@@ -556,6 +577,7 @@ static const struct strct_test_data test_data[] = {
     "name5=var_with_=_char\t \t",
     0,
     1,
+    3,
     5,
     5,
     {
@@ -573,6 +595,7 @@ static const struct strct_test_data test_data[] = {
     "name5=var_with_=_char;\t \t",
     0,
     1,
+    3,
     5,
     5,
     {
@@ -590,6 +613,7 @@ static const struct strct_test_data test_data[] = {
     "name4=\"var4 with spaces\"",
     0,
     4,
+    4,
     5,
     5,
     {
@@ -607,6 +631,7 @@ static const struct strct_test_data test_data[] = {
     "name4=\"var4 with spaces\";",
     0,
     4,
+    4,
     5,
     5,
     {
@@ -624,6 +649,7 @@ static const struct strct_test_data test_data[] = {
     "name4=\"var4 with spaces\"; name3=",
     0,
     3,
+    3,
     5,
     5,
     {
@@ -641,6 +667,7 @@ static const struct strct_test_data test_data[] = {
     "name5=var_with_=_char; name3=;",
     0,
     2,
+    2,
     5,
     5,
     {
@@ -658,6 +685,7 @@ static const struct strct_test_data test_data[] = {
     "name5=var_with_=_char",
     0,
     0,
+    3,
     5,
     5,
     {
@@ -675,6 +703,7 @@ static const struct strct_test_data test_data[] = {
     "name5=var_with_=_char",
     0,
     3,
+    3,
     5,
     5,
     {
@@ -692,6 +721,7 @@ static const struct strct_test_data test_data[] = {
     "name5=var_with_=_char;;;;;;;;",
     0,
     3,
+    3,
     5,
     5,
     {
@@ -709,6 +739,7 @@ static const struct strct_test_data test_data[] = {
     "name5=var_with_=_char; ; ; ; ; name3=",
     0,
     2,
+    2,
     5,
     5,
     {
@@ -726,14 +757,15 @@ static const struct strct_test_data test_data[] = {
     "name4=\"var4 with spaces\" ",
     0,
     0,
+    4,
     5,
     5,
     {
       COOKIE_ ("name1", "var1"),
       COOKIE_ ("name2", "var2"),
       COOKIE_ ("name3", ""),
-      COOKIE_ ("name4", "var4 with spaces"),
-      COOKIE_ ("name5", "var_with_=_char")
+      COOKIE_ ("name5", "var_with_=_char"),
+      COOKIE_ ("name4", "var4 with spaces")
     }
   },
   {
@@ -742,6 +774,7 @@ static const struct strct_test_data test_data[] = {
     "name1=var1; name2=var2; name3=",
     0,
     1,
+    1,
     5,
     5,
     {
@@ -752,12 +785,30 @@ static const struct strct_test_data test_data[] = {
       COOKIE_ ("name4", "var4 with spaces")
     }
   },
+  {
+    __LINE__,
+    "name5=var_with_=_char; name4=\"var4_without_spaces\"; " \
+    "name1=var1; name2=var2; name3=",
+    5,
+    5,
+    5,
+    5,
+    5,
+    {
+      COOKIE_ ("name5", "var_with_=_char"),
+      COOKIE_ ("name1", "var1"),
+      COOKIE_ ("name2", "var2"),
+      COOKIE_ ("name3", ""),
+      COOKIE_ ("name4", "var4_without_spaces")
+    }
+  },
   {
     __LINE__,
     "name1 = value1",
     0,
     0,
     0,
+    0,
     1,
     {
       COOKIE_ ("name1", "value1"),
@@ -773,6 +824,7 @@ static const struct strct_test_data test_data[] = {
     0,
     0,
     0,
+    0,
     1,
     {
       COOKIE_ ("name1", "value1"),
@@ -788,6 +840,7 @@ static const struct strct_test_data test_data[] = {
     0,
     0,
     0,
+    0,
     1,
     {
       COOKIE_ ("name1", "value1"),
@@ -803,6 +856,7 @@ static const struct strct_test_data test_data[] = {
     0,
     0,
     0,
+    0,
     2,
     {
       COOKIE_ ("name1", "value1"),
@@ -818,6 +872,7 @@ static const struct strct_test_data test_data[] = {
     0,
     1,
     1,
+    1,
     2,
     {
       COOKIE_ ("name1", "value1"),
@@ -833,6 +888,7 @@ static const struct strct_test_data test_data[] = {
     0,
     0,
     0,
+    0,
     2,
     {
       COOKIE_ ("name1", "value1"),
@@ -849,6 +905,7 @@ static const struct strct_test_data test_data[] = {
     0,
     0,
     0,
+    0,
     {
       COOKIE_NULL,
       COOKIE_NULL,
@@ -864,6 +921,7 @@ static const struct strct_test_data test_data[] = {
     0,
     0,
     0,
+    0,
     {
       COOKIE_NULL,
       COOKIE_NULL,
@@ -879,6 +937,7 @@ static const struct strct_test_data test_data[] = {
     0,
     0,
     0,
+    0,
     {
       COOKIE_NULL,
       COOKIE_NULL,
@@ -894,6 +953,7 @@ static const struct strct_test_data test_data[] = {
     0,
     0,
     0,
+    0,
     {
       COOKIE_NULL,
       COOKIE_NULL,
@@ -909,6 +969,7 @@ static const struct strct_test_data test_data[] = {
     0,
     0,
     0,
+    0,
     {
       COOKIE_NULL,
       COOKIE_NULL,
@@ -924,6 +985,7 @@ static const struct strct_test_data test_data[] = {
     0,
     0,
     0,
+    0,
     {
       COOKIE_NULL,
       COOKIE_NULL,
@@ -939,6 +1001,7 @@ static const struct strct_test_data test_data[] = {
     0,
     0,
     0,
+    0,
     {
       COOKIE_NULL,
       COOKIE_NULL,
@@ -954,6 +1017,7 @@ static const struct strct_test_data test_data[] = {
     0,
     0,
     0,
+    0,
     {
       COOKIE_NULL,
       COOKIE_NULL,
@@ -969,6 +1033,7 @@ static const struct strct_test_data test_data[] = {
     0,
     0,
     0,
+    0,
     {
       COOKIE_NULL,
       COOKIE_NULL,
@@ -984,6 +1049,7 @@ static const struct strct_test_data test_data[] = {
     0,
     0,
     0,
+    0,
     {
       COOKIE_NULL,
       COOKIE_NULL,
@@ -999,6 +1065,7 @@ static const struct strct_test_data test_data[] = {
     0,
     0,
     0,
+    0,
     {
       COOKIE_NULL,
       COOKIE_NULL,
@@ -1014,6 +1081,7 @@ static const struct strct_test_data test_data[] = {
     0,
     0,
     0,
+    0,
     {
       COOKIE_NULL,
       COOKIE_NULL,
@@ -1029,6 +1097,7 @@ static const struct strct_test_data test_data[] = {
     0,
     0,
     0,
+    0,
     {
       COOKIE_NULL,
       COOKIE_NULL,
@@ -1044,6 +1113,7 @@ static const struct strct_test_data test_data[] = {
     0,
     0,
     0,
+    0,
     {
       COOKIE_NULL,
       COOKIE_NULL,
@@ -1057,10 +1127,12 @@ static const struct strct_test_data test_data[] = {
 /* Global parameters */
 static int verbose;
 static int oneone;                  /**< If false use HTTP/1.0 for requests*/
-static int use_strict_n1;
-static int use_strict_zero;
-static int use_strict_p1;
-static int strict_level;
+static int use_discp_n3;
+static int use_discp_n2;
+static int use_discp_zero;
+static int use_discp_p1;
+static int use_discp_p2;
+static int discp_level;
 
 static void
 test_global_init (void)
@@ -1128,12 +1200,16 @@ ahcCheck (void *cls,
   unsigned int i;
   int cookie_failed;
 
-  if (use_strict_p1)
+  if (use_discp_p2)
+    expected_num_cookies = param->check->num_cookies_strict_p2;
+  else if (use_discp_p1)
     expected_num_cookies = param->check->num_cookies_strict_p1;
-  else if (use_strict_zero)
+  else if (use_discp_zero)
     expected_num_cookies = param->check->num_cookies_strict_zero;
-  else if (use_strict_n1)
-    expected_num_cookies = param->check->num_cookies_strict_n1;
+  else if (use_discp_n2)
+    expected_num_cookies = param->check->num_cookies_strict_n2;
+  else if (use_discp_n3)
+    expected_num_cookies = param->check->num_cookies_strict_n3;
   else
     externalErrorExit ();
 
@@ -1565,13 +1641,13 @@ testExternalPolling (void)
   if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
     port = 0;
   else
-    port = 1340 + oneone ? 0 : 6 + (uint16_t) (1 + strict_level);
+    port = 1340 + oneone ? 0 : 6 + (uint16_t) (1 + discp_level);
 
   d = MHD_start_daemon (MHD_USE_ERROR_LOG,
                         port, NULL, NULL,
                         &ahcCheck, &ahc_param,
-                        MHD_OPTION_STRICT_FOR_CLIENT,
-                        (int) (strict_level),
+                        MHD_OPTION_CLIENT_DISCIPLINE_LVL,
+                        (int) (discp_level),
                         MHD_OPTION_END);
   if (d == NULL)
     return 1;
@@ -1640,19 +1716,26 @@ main (int argc, char *const *argv)
                has_param (argc, argv, "-s") ||
                has_param (argc, argv, "--silent"));
   oneone = ! has_in_name (argv[0], "10");
-  use_strict_n1 = has_in_name (argv[0], "_strict_n1");
-  use_strict_zero = has_in_name (argv[0], "_strict_zero");
-  use_strict_p1 = has_in_name (argv[0], "_strict_p1");
-  if (1 != ((use_strict_n1 ? 1 : 0) + (use_strict_zero ? 1 : 0)
-            + (use_strict_p1 ? 1 : 0)))
+  use_discp_n3 = has_in_name (argv[0], "_discp_n3");
+  use_discp_n2 = has_in_name (argv[0], "_discp_n2");
+  use_discp_zero = has_in_name (argv[0], "_discp_zero");
+  use_discp_p1 = has_in_name (argv[0], "_discp_p1");
+  use_discp_p2 = has_in_name (argv[0], "_discp_p2");
+  if (1 != ((use_discp_n3 ? 1 : 0) + (use_discp_n2 ? 1 : 0)
+            + (use_discp_zero ? 1 : 0)
+            + (use_discp_p1 ? 1 : 0) + (use_discp_p2 ? 1 : 0)))
     return 99;
 
-  if (use_strict_n1)
-    strict_level = -1;
-  else if (use_strict_zero)
-    strict_level = 0;
-  else if (use_strict_p1)
-    strict_level = 1;
+  if (use_discp_n3)
+    discp_level = -3;
+  else if (use_discp_n2)
+    discp_level = -2;
+  else if (use_discp_zero)
+    discp_level = 0;
+  else if (use_discp_p1)
+    discp_level = 1;
+  else if (use_discp_p2)
+    discp_level = 2;
 
   test_global_init ();
 

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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