gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] branch master updated (fdf1da57 -> 20d9b03a)


From: gnunet
Subject: [taler-merchant] branch master updated (fdf1da57 -> 20d9b03a)
Date: Sun, 19 Feb 2023 12:31:03 +0100

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

grothoff pushed a change to branch master
in repository merchant.

    from fdf1da57 -doxygen fixes and configuration fixes
     new c0cbc4e8 fix use-after-free
     new 20d9b03a fix bad memory use in new test logic

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:
 ...merchant-httpd_private-post-instances-ID-auth.c |  1 -
 src/include/taler_merchant_testing_lib.h           |  3 +-
 src/testing/testing_api_cmd_checkserver.c          | 53 +++++++++++--------
 src/testing/testing_api_cmd_testserver.c           | 59 +++++++++++++++-------
 4 files changed, 73 insertions(+), 43 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_private-post-instances-ID-auth.c 
b/src/backend/taler-merchant-httpd_private-post-instances-ID-auth.c
index 8feb44f2..374a60de 100644
--- a/src/backend/taler-merchant-httpd_private-post-instances-ID-auth.c
+++ b/src/backend/taler-merchant-httpd_private-post-instances-ID-auth.c
@@ -231,7 +231,6 @@ TMH_private_post_instances_default_ID_auth (const struct 
TMH_RequestHandler *rh,
   ret = post_instances_ID_auth (mi,
                                 connection,
                                 hc);
-  mi->auth_override = false;
   return ret;
 }
 
diff --git a/src/include/taler_merchant_testing_lib.h 
b/src/include/taler_merchant_testing_lib.h
index a749b092..1039d2ef 100644
--- a/src/include/taler_merchant_testing_lib.h
+++ b/src/include/taler_merchant_testing_lib.h
@@ -1891,7 +1891,8 @@ TALER_TESTING_cmd_checkserver2 (const char *label,
   op (urls, char *) \
   op (http_methods, char *)   \
   op (http_header, char *)   \
-  op (http_body, char *)   \
+  op (http_body, void *)   \
+  op (http_body_size, size_t)   \
   op (planchet_secrets, const struct TALER_PlanchetMasterSecretP)
 
 
diff --git a/src/testing/testing_api_cmd_checkserver.c 
b/src/testing/testing_api_cmd_checkserver.c
index 55f0b50d..56b05438 100644
--- a/src/testing/testing_api_cmd_checkserver.c
+++ b/src/testing/testing_api_cmd_checkserver.c
@@ -93,10 +93,11 @@ checkserver_run (void *cls,
 {
   struct CheckState *cs = cls;
   const struct TALER_TESTING_Command *ref;
-  char **expected_url;
-  char **expected_http_method;
-  char **expected_header;
-  char **expected_body;
+  char **url;
+  char **http_method;
+  char **header;
+  void **body;
+  size_t *body_size;
 
   (void) cmd;
   cs->is = is;
@@ -113,7 +114,7 @@ checkserver_run (void *cls,
   if (GNUNET_OK !=
       TALER_TESTING_get_trait_urls (ref,
                                     cs->index,
-                                    &expected_url))
+                                    &url))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                 "Trait url does not work\n");
@@ -121,7 +122,7 @@ checkserver_run (void *cls,
     TALER_TESTING_interpreter_fail (is);
     return;
   }
-  if (NULL == *expected_url)
+  if (NULL == *url)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                 "Trait for url is NULL!?\n");
@@ -130,22 +131,22 @@ checkserver_run (void *cls,
     return;
   }
   if (0 != strcmp (cs->expected_url,
-                   *expected_url))
+                   *url))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                 "URL does not match: `%s' != `%s'\n",
                 cs->expected_url,
-                *expected_url);
+                *url);
     TALER_TESTING_interpreter_fail (is);
     return;
   }
   if (GNUNET_OK !=
       TALER_TESTING_get_trait_http_methods (ref,
                                             cs->index,
-                                            &expected_http_method))
+                                            &http_method))
     TALER_TESTING_interpreter_fail (is);
   if (0 != strcmp (cs->expected_method,
-                   *expected_http_method))
+                   *http_method))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                 "http_method does not match\n");
@@ -155,36 +156,44 @@ checkserver_run (void *cls,
   if (GNUNET_OK !=
       TALER_TESTING_get_trait_http_header (ref,
                                            cs->index,
-                                           &expected_header))
+                                           &header))
     TALER_TESTING_interpreter_fail (is);
-  if ( ( (NULL == cs->expected_header) && (NULL != *expected_header)) ||
-       ( (NULL != cs->expected_header) && (NULL == expected_header)) ||
+  if ( ( (NULL == cs->expected_header) && (NULL != *header)) ||
+       ( (NULL != cs->expected_header) && (NULL == header)) ||
        ( (NULL != cs->expected_header) &&
          (0 != strcmp (cs->expected_header,
-                       *expected_header)) ) )
+                       *header)) ) )
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                 "header does not match: `%s' != `%s'\n",
                 cs->expected_header,
-                *expected_header);
+                *header);
     TALER_TESTING_interpreter_fail (is);
     return;
   }
   if (GNUNET_OK !=
       TALER_TESTING_get_trait_http_body (ref,
                                          cs->index,
-                                         &expected_body))
+                                         &body))
     TALER_TESTING_interpreter_fail (is);
-  if ( ( (NULL == cs->expected_body) && (NULL != *expected_body)) ||
-       ( (NULL != cs->expected_body) && (NULL == expected_body)) ||
+  if (GNUNET_OK !=
+      TALER_TESTING_get_trait_http_body_size (ref,
+                                              cs->index,
+                                              &body_size))
+    TALER_TESTING_interpreter_fail (is);
+  if ( ( (NULL == cs->expected_body) && (NULL != *body)) ||
+       ( (NULL != cs->expected_body) && (NULL == body)) ||
        ( (NULL != cs->expected_body) &&
-         (0 != strcmp (cs->expected_body,
-                       *expected_body) ) ) )
+         ( (*body_size != strlen (cs->expected_body)) ||
+           (0 != memcmp (cs->expected_body,
+                         *body,
+                         *body_size) ) ) ) )
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                "body does not match : `%s' and `%s'\n",
+                "body does not match : `%s' and `%.*s'\n",
                 cs->expected_body,
-                *expected_body);
+                (int) *body_size,
+                (const char *) *body);
     TALER_TESTING_interpreter_fail (is);
     return;
   }
diff --git a/src/testing/testing_api_cmd_testserver.c 
b/src/testing/testing_api_cmd_testserver.c
index d06ce824..c5a929c0 100644
--- a/src/testing/testing_api_cmd_testserver.c
+++ b/src/testing/testing_api_cmd_testserver.c
@@ -73,7 +73,7 @@ struct RequestCtx
   /**
    * body of the webhook.
    */
-  char *body;
+  void *body;
 
   /**
    * size of the body
@@ -136,7 +136,6 @@ handler_cb (void *cls,
 {
   struct TestserverState *ts = cls;
   struct RequestCtx *rc = *con_cls;
-  json_t *body;
 
   (void) version;
   if (NULL == rc)
@@ -165,12 +164,14 @@ handler_cb (void *cls,
   if (0 == strcasecmp (method,
                        MHD_HTTP_METHOD_GET))
   {
-    body = GNUNET_JSON_PACK (
+    json_t *reply;
+
+    reply = GNUNET_JSON_PACK (
       GNUNET_JSON_pack_string (
         "status",
         "success"));
     return TALER_MHD_reply_json_steal (connection,
-                                       body,
+                                       reply,
                                        MHD_HTTP_OK);
   }
   if (0 != strcasecmp (method,
@@ -181,19 +182,35 @@ handler_cb (void *cls,
   }
   if (0 != *upload_data_size)
   {
-    rc->body = GNUNET_strdup(upload_data);
+    void *body;
+
+    body = GNUNET_malloc (rc->body_size + *upload_data_size);
+    memcpy (body,
+            rc->body,
+            rc->body_size);
+    GNUNET_free (rc->body);
+    memcpy (body + rc->body_size,
+            upload_data,
+            *upload_data_size);
+    rc->body = body;
+    rc->body_size += *upload_data_size;
     *upload_data_size = 0;
     GNUNET_array_append (ts->rcs,
                          ts->rcs_length,
                          rc);
     return MHD_YES;
   }
-  body = GNUNET_JSON_PACK (
-    GNUNET_JSON_pack_string ("something",
-                             "good"));
-  return TALER_MHD_reply_json_steal (connection,
-                                     body,
-                                     MHD_HTTP_OK);
+
+  {
+    json_t *reply;
+
+    reply = GNUNET_JSON_PACK (
+      GNUNET_JSON_pack_string ("something",
+                               "good"));
+    return TALER_MHD_reply_json_steal (connection,
+                                       reply,
+                                       MHD_HTTP_OK);
+  }
 }
 
 
@@ -259,7 +276,7 @@ testserver_cleanup (void *cls,
   struct TestserverState *ser = cls;
 
   (void) cmd;
-  for (unsigned int i=0;i<ser->rcs_length-1;i++)
+  for (unsigned int i = 0; i<ser->rcs_length - 1; i++)
   {
     struct RequestCtx *rc = ser->rcs[i];
 
@@ -295,15 +312,19 @@ traits_testserver (void *cls,
   {
     struct RequestCtx *rc = ser->rcs[index];
     struct TALER_TESTING_Trait traits[] = {
-      TALER_TESTING_make_trait_urls (index, &rc->url),
-      TALER_TESTING_make_trait_http_methods (index, &rc->http_method),
-      TALER_TESTING_make_trait_http_header (index, &rc->header),
-      TALER_TESTING_make_trait_http_body (index, &rc->body),
+      TALER_TESTING_make_trait_urls (index,
+                                     &rc->url),
+      TALER_TESTING_make_trait_http_methods (index,
+                                             &rc->http_method),
+      TALER_TESTING_make_trait_http_header (index,
+                                            &rc->header),
+      TALER_TESTING_make_trait_http_body (index,
+                                          &rc->body),
+      TALER_TESTING_make_trait_http_body_size (index,
+                                               &rc->body_size),
       TALER_TESTING_trait_end (),
     };
 
-    fprintf (stdout, "\n\nbody %s\n\n", rc->body);
-
     return TALER_TESTING_get_trait (traits,
                                     ret,
                                     trait,
@@ -311,6 +332,7 @@ traits_testserver (void *cls,
   }
 }
 
+
 /**
  * This function is used to start the web server.
  *
@@ -340,4 +362,3 @@ TALER_TESTING_cmd_testserver (const char *label,
 
 
 /* end of testing_api_cmd_checkserver.c */
-

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