[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-twister] 10/11: do not use "tmp" buffer for response
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-twister] 10/11: do not use "tmp" buffer for response |
Date: |
Wed, 16 May 2018 10:42:05 +0200 |
This is an automated email from the git hooks/post-receive script.
marcello pushed a commit to branch master
in repository twister.
commit a1537b1d94677db84807a755f134b076d2b728e6
Author: Marcello Stanisci <address@hidden>
AuthorDate: Tue May 15 17:36:02 2018 +0200
do not use "tmp" buffer for response
---
src/twister/taler-twister-service.c | 69 ++++++++++++++++++-------------------
1 file changed, 33 insertions(+), 36 deletions(-)
diff --git a/src/twister/taler-twister-service.c
b/src/twister/taler-twister-service.c
index 8ace6f6..cbe58b7 100644
--- a/src/twister/taler-twister-service.c
+++ b/src/twister/taler-twister-service.c
@@ -542,7 +542,8 @@ curl_download_cb (void *ptr,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Curl download proceeding\n");
- GNUNET_assert (REQUEST_STATE_DOWNLOAD_STARTED == hr->state);
+ GNUNET_assert
+ (REQUEST_STATE_DOWNLOAD_STARTED == hr->state);
if (hr->io_size - hr->io_len < total)
{
@@ -553,6 +554,7 @@ curl_download_cb (void *ptr,
GNUNET_MAX (total + hr->io_len,
hr->io_size * 2 + 1024));
}
+
GNUNET_memcpy (&hr->io_buf[hr->io_len],
ptr,
total);
@@ -581,6 +583,10 @@ curl_upload_cb (void *buf,
size_t len = size * nmemb;
size_t to_copy;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Uploader cb, size: %u.\n",
+ size);
+
if (REQUEST_STATE_UPLOAD_STARTED != hr->state)
{
GNUNET_break (0);
@@ -1177,9 +1183,6 @@ create_response (void *cls,
(void) cls;
(void) url;
- char *body;
- size_t body_len;
-
if (NULL == hr)
{
GNUNET_break (0);
@@ -1196,7 +1199,9 @@ create_response (void *cls,
/* continuing to process request */
if (0 != *upload_data_size)
{
- GNUNET_assert (REQUEST_STATE_UPLOAD_STARTED == hr->state);
+ GNUNET_assert
+ (REQUEST_STATE_UPLOAD_STARTED == hr->state);
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Processing %u bytes UPLOAD\n",
(unsigned int) *upload_data_size);
@@ -1226,49 +1231,41 @@ create_response (void *cls,
return MHD_YES;
}
- /* Malform request body. Note, this flag will be
- * cleared only after having set the right malformed
- * body lenght in the request headers. */
- if (GNUNET_YES == malform_upload)
- {
- TALER_LOG_DEBUG
- ("Will (badly) truncate the request.\n");
- malformed_size = GNUNET_CRYPTO_random_u32
- (GNUNET_CRYPTO_QUALITY_WEAK, hr->io_len);
- hr->io_len = malformed_size;
- }
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "About to check flip path UL: %s\n",
- flip_path_ul);
-
/* Upload (from the *client*) finished,
* generate curl request to the proxied service. */
if (NULL == hr->curl)
{
+ /* Malform request body. Note, this flag will be
+ * cleared only after having set the right malformed
+ * body lenght in the request headers. */
+ if (GNUNET_YES == malform_upload)
+ {
+ TALER_LOG_DEBUG
+ ("Will (badly) truncate the request.\n");
+ malformed_size = GNUNET_CRYPTO_random_u32
+ (GNUNET_CRYPTO_QUALITY_WEAK, hr->io_len);
+ hr->io_len = malformed_size;
+ }
+
if ('\0' != flip_path_ul[0])
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Going to modify the upload object (%s)\n",
hr->io_buf);
json_t *tmp;
-
tmp = json_loads (hr->io_buf,
JSON_REJECT_DUPLICATES,
NULL);
flip_object (con,
tmp,
flip_path_ul);
-
- /* No need to update 'io_length', as flipping a
+ /* No need to update 'io_len', as flipping a
* bit does not change the data size. */
hr->io_buf = json_dumps (tmp,
JSON_COMPACT);
-
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Flipped (?) upload object (%s)\n",
hr->io_buf);
-
json_decref (tmp);
}
@@ -1482,14 +1479,13 @@ create_response (void *cls,
modify_object (con, hr);
}
- body_len = hr->io_len;
- body = hr->io_buf;
if (NULL != hr->json)
{
TALER_LOG_DEBUG ("Parsing final JSON.\n");
- body = json_dumps (hr->json, JSON_COMPACT);
- body_len = strlen (body);
+ GNUNET_free (hr->io_buf);
+ hr->io_buf = json_dumps (hr->json, JSON_COMPACT);
+ hr->io_len = strlen (hr->io_buf);
json_decref (hr->json);
}
@@ -1500,17 +1496,16 @@ create_response (void *cls,
TALER_LOG_DEBUG
("Will (badly) truncate the response.\n");
fake_len = GNUNET_CRYPTO_random_u32
- (GNUNET_CRYPTO_QUALITY_WEAK, body_len);
- body_len = fake_len;
+ (GNUNET_CRYPTO_QUALITY_WEAK, hr->io_len);
+ hr->io_len = fake_len;
malform = GNUNET_NO;
}
hr->response = MHD_create_response_from_buffer
- (body_len,
- body,
+ (hr->io_len,
+ hr->io_buf,
MHD_RESPMEM_MUST_COPY);
- GNUNET_free_non_null (body);
for (header = hr->header_head;
NULL != header;
header = header->next)
@@ -1594,11 +1589,13 @@ mhd_completed_cb (void *cls,
GNUNET_free (header->value);
GNUNET_free (header);
}
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Finished request for %s\n",
hr->url);
+
GNUNET_free (hr->url);
- GNUNET_free_non_null (hr->io_buf);
+ GNUNET_free (hr->io_buf);
GNUNET_free (hr);
*con_cls = NULL;
}
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [taler-twister] branch master updated (2e773e8 -> 5ac6f8f), gnunet, 2018/05/16
- [GNUnet-SVN] [taler-twister] 11/11: json_dumpb() way better., gnunet, 2018/05/16
- [GNUnet-SVN] [taler-twister] 06/11: dumping stringified flipped object into io_buf., gnunet, 2018/05/16
- [GNUnet-SVN] [taler-twister] 09/11: debug stmt, gnunet, 2018/05/16
- [GNUnet-SVN] [taler-twister] 05/11: object "walker" is HttpResponse-agnostic., gnunet, 2018/05/16
- [GNUnet-SVN] [taler-twister] 03/11: Bring difference into the service component., gnunet, 2018/05/16
- [GNUnet-SVN] [taler-twister] 08/11: export "flippers" to the internal API., gnunet, 2018/05/16
- [GNUnet-SVN] [taler-twister] 02/11: Differentiate between bit-flipping in download and upload., gnunet, 2018/05/16
- [GNUnet-SVN] [taler-twister] 01/11: Walk objects.., gnunet, 2018/05/16
- [GNUnet-SVN] [taler-twister] 10/11: do not use "tmp" buffer for response,
gnunet <=
- [GNUnet-SVN] [taler-twister] 04/11: cosmetics., gnunet, 2018/05/16
- [GNUnet-SVN] [taler-twister] 07/11: debug stmt, gnunet, 2018/05/16