gnunet-svn
[Top][All Lists]
Advanced

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

[libmicrohttpd] branch master updated (6dd2096b -> 1cf2ccde)


From: gnunet
Subject: [libmicrohttpd] branch master updated (6dd2096b -> 1cf2ccde)
Date: Wed, 15 Sep 2021 18:47:32 +0200

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

karlson2k pushed a change to branch master
in repository libmicrohttpd.

    from 6dd2096b Fixed f032145edcb39e0445e4f78fec51867b9f89706c
     new e3ed5e0d test_postprocessor: improved error reporting
     new 1cf2ccde test_postprocessor: added test with double value

The 2 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/microhttpd/test_postprocessor.c | 84 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 83 insertions(+), 1 deletion(-)

diff --git a/src/microhttpd/test_postprocessor.c 
b/src/microhttpd/test_postprocessor.c
index 36e5638c..b3231c0e 100644
--- a/src/microhttpd/test_postprocessor.c
+++ b/src/microhttpd/test_postprocessor.c
@@ -143,11 +143,12 @@ value_checker (void *cls,
 
 #if MHD_DEBUG_PP
   fprintf (stderr,
-           "VC: `%s' `%s' `%s' `%s' `%.*s' (%d)\n",
+           "VC: `%s' `%s' `%s' `%s' (+%u)`%.*s' (%d)\n",
            key ? key : "(NULL)",
            filename ? filename : "(NULL)",
            content_type ? content_type : "(NULL)",
            transfer_encoding ? transfer_encoding : "(NULL)",
+           (unsigned int) off,
            (int) (data ? size : 6),
            data ? data : "(NULL)",
            (int) size);
@@ -706,6 +707,86 @@ test_empty_key (void)
 }
 
 
+static int
+test_double_value (void)
+{
+  const char form_data[] = URL_DATA "=abcdef";
+  size_t step;
+  const size_t size = MHD_STATICSTR_LEN_ (form_data);
+  const size_t safe_size = MHD_STATICSTR_LEN_ (URL_DATA);
+
+  for (step = 1; size >= step; ++step)
+  {
+    size_t i;
+    struct MHD_Connection connection;
+    struct MHD_HTTP_Header header;
+    struct MHD_PostProcessor *pp;
+    unsigned int results_off = URL_START;
+    unsigned int results_final = results_off + 1; /* First value is correct */
+    memset (&connection, 0, sizeof (struct MHD_Connection));
+    memset (&header, 0, sizeof (struct MHD_HTTP_Header));
+
+    connection.headers_received = &header;
+    connection.headers_received_tail = &header;
+    header.header = MHD_HTTP_HEADER_CONTENT_TYPE;
+    header.header_size = MHD_STATICSTR_LEN_ (MHD_HTTP_HEADER_CONTENT_TYPE);
+    header.value = MHD_HTTP_POST_ENCODING_FORM_URLENCODED;
+    header.value_size =
+      MHD_STATICSTR_LEN_ (MHD_HTTP_POST_ENCODING_FORM_URLENCODED);
+    header.kind = MHD_HEADER_KIND;
+    pp = MHD_create_post_processor (&connection,
+                                    1024, &value_checker, &results_off);
+    if (NULL == pp)
+    {
+      fprintf (stderr, "Failed to create post processor.\n"
+               "Line: %u\n", (unsigned int) __LINE__);
+      exit (50);
+    }
+    for (i = 0; size > i; i += step)
+    {
+      if (MHD_NO != MHD_post_process (pp,
+                                      form_data + i,
+                                      (step > size - i) ? (size - i) : step))
+      {
+        if (safe_size == i + step)
+          results_final = URL_END;
+        if (safe_size < i + step)
+        {
+          fprintf (stderr, "Succeed to process the broken data.\n"
+                   "i: %u. step: %u.\n"
+                   "Line: %u\n", (unsigned) i, (unsigned) step,
+                   (unsigned int) __LINE__);
+          exit (49);
+        }
+      }
+      else
+      {
+        if (safe_size >= i + step)
+        {
+          fprintf (stderr, "Failed to process the data.\n"
+                   "i: %u. step: %u.\n"
+                   "Line: %u\n", (unsigned) i, (unsigned) step,
+                   (unsigned int) __LINE__);
+          exit (49);
+        }
+      }
+    }
+    MHD_destroy_post_processor (pp);
+    if (results_final != results_off)
+    {
+      fprintf (stderr,
+               "Test failed in line %u.\tStep:%u\n Got: %u\tExpected: %u\n",
+               (unsigned int) __LINE__,
+               (unsigned int) step,
+               results_off,
+               results_final);
+      return 1;
+    }
+  }
+  return 0;
+}
+
+
 int
 main (int argc, char *const *argv)
 {
@@ -718,6 +799,7 @@ main (int argc, char *const *argv)
   errorCount += test_multipart ();
   errorCount += test_nested_multipart ();
   errorCount += test_empty_key ();
+  errorCount += test_double_value ();
   errorCount += test_overflow ();
   if (errorCount != 0)
     fprintf (stderr, "Error (code: %u)\n", errorCount);

-- 
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]