#include <zstd.h>
#endif
+#include "connect.h"
#include "sendf.h"
#include "curl_trc.h"
#include "content_encoding.h"
z_const Bytef *orig_in = z->next_in;
bool done = FALSE;
CURLcode result = CURLE_OK; /* Curl_client_write status */
+ int i = 0;
/* Check state. */
if(zp->zlib_init != ZLIB_INIT &&
int status; /* zlib status */
done = TRUE;
+ if(++i > (1024 * 1024 / DECOMPRESS_BUFFER_SIZE)) {
+ /* check every MB of output if we are not exceeding time limit */
+ i = 0;
+ if(Curl_timeleft_ms(data) < 0) {
+ failf(data, "Operation timed out while decoding payload");
+ return exit_zlib(data, z, &zp->zlib_init, CURLE_OPERATION_TIMEDOUT);
+ }
+ }
+
/* (re)set buffer for decompressed output for every iteration */
z->next_out = (Bytef *)zp->buffer;
z->avail_out = DECOMPRESS_BUFFER_SIZE;
size_t dstleft;
CURLcode result = CURLE_OK;
BrotliDecoderResult r = BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT;
+ int i = 0;
if(!(type & CLIENTWRITE_BODY) || !nbytes)
return Curl_cwriter_write(data, writer->next, type, buf, nbytes);
while((nbytes || r == BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT) &&
result == CURLE_OK) {
+
+ if(++i > (1024 * 1024 / DECOMPRESS_BUFFER_SIZE)) {
+ /* check every MB of output if we are not exceeding time limit */
+ i = 0;
+ if(Curl_timeleft_ms(data) < 0) {
+ failf(data, "Operation timed out while decoding payload");
+ return CURLE_OPERATION_TIMEDOUT;
+ }
+ }
+
dst = (uint8_t *)bp->buffer;
dstleft = DECOMPRESS_BUFFER_SIZE;
r = BrotliDecoderDecompressStream(bp->br,
ZSTD_inBuffer in;
ZSTD_outBuffer out;
size_t errorCode;
+ int i = 0;
if(!(type & CLIENTWRITE_BODY) || !nbytes)
return Curl_cwriter_write(data, writer->next, type, buf, nbytes);
in.size = nbytes;
for(;;) {
+ if(++i > (1024 * 1024 / DECOMPRESS_BUFFER_SIZE)) {
+ /* check every MB of output if we are not exceeding time limit */
+ i = 0;
+ if(Curl_timeleft_ms(data) < 0) {
+ failf(data, "Operation timed out while decoding payload");
+ return CURLE_OPERATION_TIMEDOUT;
+ }
+ }
+
out.pos = 0;
out.dst = zp->buffer;
out.size = DECOMPRESS_BUFFER_SIZE;