commit 5c8e7af7fa78e8a9e8f643749ae01254909ed28d
parent 69fb5834f81930672d52f4dd8503086e25957822
Author: Christian Grothoff <christian@grothoff.org>
Date: Fri, 9 May 2025 15:52:34 +0200
-fix more 0-length issues
Diffstat:
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/src/twister/taler-twister-service.c b/src/twister/taler-twister-service.c
@@ -641,7 +641,8 @@ curl_upload_cb (void *buf,
* We got rescheduled because the download callback was asleep.
* FIXME: can this block be eliminated and the unpausing being
* moved in the last block where we return zero as well?
- */if ( (0 == hr->io_len) &&
+ */
+ if ( (0 == hr->io_len) &&
(REQUEST_STATE_PROXY_DOWNLOAD_STARTED == hr->state) )
{
if (GNUNET_YES == hr->curl_paused)
@@ -1325,7 +1326,8 @@ inflate_data (struct HttpRequest *request)
memset (&z, 0, sizeof (z));
z.next_in = (Bytef *) request->io_buf;
z.avail_in = request->io_len;
- tmp_size = GNUNET_MIN (REQUEST_BUFFER_MAX, request->io_len * 4);
+ tmp_size = GNUNET_MIN (REQUEST_BUFFER_MAX,
+ request->io_len * 4);
tmp = GNUNET_malloc (tmp_size);
z.next_out = (Bytef *) tmp;
z.avail_out = tmp_size;
@@ -1581,12 +1583,12 @@ create_response (void *cls,
/* Malform request body. Note, this flag will be
* cleared only after having set the right malformed
* body length in the request headers. */
- if (GNUNET_YES == malform_upload)
+ if ( (GNUNET_YES == malform_upload) &&
+ (hr->io_len > 0) )
{
- TWISTER_LOG_DEBUG
- ("Will (badly) truncate the request.\n");
- malformed_size = GNUNET_CRYPTO_random_u32
- (GNUNET_CRYPTO_QUALITY_WEAK, hr->io_len);
+ TWISTER_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;
malform_upload = GNUNET_NO;
}
@@ -1906,13 +1908,15 @@ create_response (void *cls,
if (GNUNET_YES == malform)
{
- size_t fake_len;
-
TWISTER_LOG_DEBUG ("Will (badly) truncate the response.\n");
if (hr->io_len > 0)
+ {
+ size_t fake_len;
+
fake_len = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
hr->io_len);
- hr->io_len = fake_len;
+ hr->io_len = fake_len;
+ }
malform = GNUNET_NO;
}