gnunet-svn
[Top][All Lists]
Advanced

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

[libmicrohttpd] branch master updated (f84bdf0a -> 34aa038d)


From: gnunet
Subject: [libmicrohttpd] branch master updated (f84bdf0a -> 34aa038d)
Date: Wed, 10 Jun 2020 21:51:13 +0200

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

grothoff pushed a change to branch master
in repository libmicrohttpd.

    from f84bdf0a Sanitized all log and error messages.
     new 79748e57 add additional PP test from MD
     new a0190573 fix PP bug discovered by MD
     new 34aa038d Merge branch 'master' of git+ssh://gnunet.org/libmicrohttpd

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                              |   4 +
 src/microhttpd/Makefile.am             |   4 +
 src/microhttpd/postprocessor.c         |   1 +
 src/microhttpd/test_postprocessor_md.c | 132 +++++++++++++++++++++++++++++++++
 4 files changed, 141 insertions(+)
 create mode 100644 src/microhttpd/test_postprocessor_md.c

diff --git a/ChangeLog b/ChangeLog
index 9fede6ae..a8940d51 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Wed 10 Jun 2020 09:44:29 PM CEST
+    Fixed PostProcessor bug discovered by MD, which given certain parser
+    boundaries caused the returned values to be wrong. -CG/MD
+
 Wed 08 Apr 2020 10:53:01 PM CEST
     Introduce `enum MHD_Result` for #MHD_YES/#MHD_NO to avoid using 'int' so 
much.
     Note that this change WILL cause compiler warnings until (most) MHD 
callbacks
diff --git a/src/microhttpd/Makefile.am b/src/microhttpd/Makefile.am
index 19899a40..87de3c9b 100644
--- a/src/microhttpd/Makefile.am
+++ b/src/microhttpd/Makefile.am
@@ -161,6 +161,7 @@ check_PROGRAMS = \
   test_sha256 \
   test_start_stop \
   test_daemon \
+  test_postprocessor_md \
   test_options
 
 if HAVE_POSIX_THREADS
@@ -342,6 +343,9 @@ test_str_to_value_SOURCES = \
 test_str_token_SOURCES = \
   test_str_token.c mhd_str.c
 
+test_postprocessor_md_SOURCES = \
+  test_postprocessor_md.c
+
 test_http_reasons_SOURCES = \
   test_http_reasons.c \
   reason_phrase.c mhd_str.c mhd_str.h
diff --git a/src/microhttpd/postprocessor.c b/src/microhttpd/postprocessor.c
index 9c464152..8848b306 100644
--- a/src/microhttpd/postprocessor.c
+++ b/src/microhttpd/postprocessor.c
@@ -541,6 +541,7 @@ post_process_urlencoded (struct MHD_PostProcessor *pp,
           pp->buffer_pos = 0;
           pp->value_offset = 0;
           pp->state = PP_Init;
+          start_value = NULL;
         }
         continue;
       case '\n':
diff --git a/src/microhttpd/test_postprocessor_md.c 
b/src/microhttpd/test_postprocessor_md.c
new file mode 100644
index 00000000..1e9e4143
--- /dev/null
+++ b/src/microhttpd/test_postprocessor_md.c
@@ -0,0 +1,132 @@
+/*
+     This file is part of libmicrohttpd
+     Copyright (C) 2020 Christian Grothoff
+
+     libmicrohttpd is free software; you can redistribute it and/or modify
+     it under the terms of the GNU General Public License as published
+     by the Free Software Foundation; either version 3, or (at your
+     option) any later version.
+
+     libmicrohttpd is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     General Public License for more details.
+
+     You should have received a copy of the GNU General Public License
+     along with libmicrohttpd; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+     Boston, MA 02110-1301, USA.
+*/
+/**
+ * @file test_postprocessor.c
+ * @brief  Testcase for postprocessor, keys with no value
+ * @author Markus Doppelbauer
+ */
+#include "MHD_config.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <microhttpd.h>
+
+/**
+ * Handler for fatal errors.
+ */
+MHD_PanicCallback mhd_panic;
+
+/**
+ * Closure argument for #mhd_panic.
+ */
+void *mhd_panic_cls;
+
+
+enum MHD_Result
+MHD_lookup_connection_value_n (struct MHD_Connection *connection,
+                               enum MHD_ValueKind kind,
+                               const char *key,
+                               size_t key_size,
+                               const char **value_ptr,
+                               size_t *value_size_ptr)
+{
+  return MHD_NO;
+}
+
+
+#include "mhd_str.c"
+#include "internal.c"
+#include "postprocessor.c"
+
+
+static unsigned int found;
+
+
+static enum MHD_Result
+post_data_iterator (void *cls,
+                    enum MHD_ValueKind kind,
+                    const char *key,
+                    const char *filename,
+                    const char *content_type,
+                    const char *transfer_encoding,
+                    const char *data,
+                    uint64_t off,
+                    size_t size)
+{
+  fprintf (stderr,
+           "%s\t%s\n",
+           key,
+           data);
+  if (0 == strcmp (key, "xxxx"))
+  {
+    if ( (4 != size) ||
+         (0 != memcmp (data, "xxxx", 4)) )
+      exit (1);
+    found |= 1;
+  }
+  if (0 == strcmp (key, "yyyy"))
+  {
+    if ( (4 != size) ||
+         (0 != memcmp (data, "yyyy", 4)) )
+      exit (1);
+    found |= 2;
+  }
+  if (0 == strcmp (key, "zzzz"))
+  {
+    if (0 != size)
+      exit (1);
+    found |= 4;
+  }
+  if (0 == strcmp (key, "aaaa"))
+  {
+    if (0 != size)
+      exit (1);
+    found |= 8;
+  }
+  return MHD_YES;
+}
+
+
+int
+main (int argc, char *argv[])
+{
+  struct MHD_PostProcessor *postprocessor;
+
+  postprocessor = malloc (sizeof (struct MHD_PostProcessor)
+                          + 0x1000 + 1);
+  if (NULL == postprocessor)
+    return 77;
+  memset (postprocessor,
+          0,
+          sizeof (struct MHD_PostProcessor) + 0x1000 + 1);
+  postprocessor->ikvi = &post_data_iterator;
+  postprocessor->encoding = MHD_HTTP_POST_ENCODING_FORM_URLENCODED;
+  postprocessor->buffer_size = 0x1000;
+  postprocessor->state = PP_Init;
+  postprocessor->skip_rn = RN_Inactive;
+  MHD_post_process (postprocessor, "xxxx=xxxx", 9);
+  MHD_post_process (postprocessor, "&yyyy=yyyy&zzzz=&aaaa=", 22);
+  MHD_post_process (postprocessor, "", 0);
+  if (MHD_YES !=
+      MHD_destroy_post_processor (postprocessor))
+    exit (3);
+  if (found != 15)
+    exit (2);
+  return EXIT_SUCCESS;
+}

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