gnunet-svn
[Top][All Lists]
Advanced

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

[libmicrohttpd] 12/15: test_head: added check for excess data in reply


From: gnunet
Subject: [libmicrohttpd] 12/15: test_head: added check for excess data in reply
Date: Fri, 28 Oct 2022 11:22:01 +0200

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

karlson2k pushed a commit to branch master
in repository libmicrohttpd.

commit b44b4f73dd5e3920983f885722a4b7a572b41e10
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Sat Oct 22 18:28:09 2022 +0300

    test_head: added check for excess data in reply
---
 src/testcurl/test_head.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/src/testcurl/test_head.c b/src/testcurl/test_head.c
index 6ce78217..27daf66e 100644
--- a/src/testcurl/test_head.c
+++ b/src/testcurl/test_head.c
@@ -434,6 +434,54 @@ setCURL_rq_path (CURL *c, int uri_exist)
 }
 
 
+static int
+libcurl_debug_cb (CURL *handle,
+                  curl_infotype type,
+                  char *data,
+                  size_t size,
+                  void *userptr)
+{
+  static const char excess_mark[] = "Excess found";
+  static const size_t excess_mark_len = MHD_STATICSTR_LEN_ (excess_mark);
+
+  (void) handle;
+  (void) userptr;
+
+#ifdef _DEBUG
+  switch (type)
+  {
+  case CURLINFO_TEXT:
+    fprintf (stderr, "* %.*s", (int) size, data);
+    break;
+  case CURLINFO_HEADER_IN:
+    fprintf (stderr, "< %.*s", (int) size, data);
+    break;
+  case CURLINFO_HEADER_OUT:
+    fprintf (stderr, "> %.*s", (int) size, data);
+    break;
+  case CURLINFO_DATA_IN:
+#if 0
+    fprintf (stderr, "<| %.*s\n", (int) size, data);
+#endif
+    break;
+  case CURLINFO_DATA_OUT:
+  case CURLINFO_SSL_DATA_IN:
+  case CURLINFO_SSL_DATA_OUT:
+  case CURLINFO_END:
+  default:
+    break;
+  }
+#endif /* _DEBUG */
+  if (CURLINFO_TEXT == type)
+  {
+    if ((size >= excess_mark_len) &&
+        (0 == memcmp (data, excess_mark, excess_mark_len)))
+      mhdErrorExitDesc ("Extra data has been detected in MHD reply");
+  }
+  return 0;
+}
+
+
 static CURL *
 setupCURL (void *cbc, uint16_t port,
            struct headers_check_result *hdr_chk_result)
@@ -466,6 +514,8 @@ setupCURL (void *cbc, uint16_t port,
 #ifdef _DEBUG
       (CURLE_OK != curl_easy_setopt (c, CURLOPT_VERBOSE, 1L)) ||
 #endif /* _DEBUG */
+      (CURLE_OK != curl_easy_setopt (c, CURLOPT_DEBUGFUNCTION,
+                                     &libcurl_debug_cb)) ||
 #if CURL_AT_LEAST_VERSION (7, 19, 4)
       (CURLE_OK != curl_easy_setopt (c, CURLOPT_PROTOCOLS, CURLPROTO_HTTP)) ||
 #endif /* CURL_AT_LEAST_VERSION (7, 19, 4) */

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