From: Daniel Stenberg Date: Mon, 4 Jul 2022 17:41:52 +0000 (+0200) Subject: urldata: make 'buffer_size' an unsigned int X-Git-Tag: curl-7_85_0~196 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3fa343a35c9d65ebbcad5d028bbd6f14cde1af00;p=thirdparty%2Fcurl.git urldata: make 'buffer_size' an unsigned int It is already capped at READBUFFER_MAX which fits easily in 32 bits. Closes #9098 --- diff --git a/lib/pingpong.c b/lib/pingpong.c index cd55173261..74a678a1a4 100644 --- a/lib/pingpong.c +++ b/lib/pingpong.c @@ -398,7 +398,8 @@ CURLcode Curl_pp_readresp(struct Curl_easy *data, } else if(keepon) { - if((perline == gotbytes) && (gotbytes > data->set.buffer_size/2)) { + if((perline == gotbytes) && + (gotbytes > (ssize_t)data->set.buffer_size/2)) { /* We got an excessive line without newlines and we need to deal with it. We keep the first bytes of the line then we throw away the rest. */ diff --git a/lib/setopt.c b/lib/setopt.c index bb0e700fbc..ba36b495c1 100644 --- a/lib/setopt.c +++ b/lib/setopt.c @@ -2238,7 +2238,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param) else if(arg < READBUFFER_MIN) arg = READBUFFER_MIN; - data->set.buffer_size = arg; + data->set.buffer_size = (int)arg; break; case CURLOPT_UPLOAD_BUFFERSIZE: diff --git a/lib/urldata.h b/lib/urldata.h index 8c38bbd18c..e8aa930410 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -1744,7 +1744,7 @@ struct UserDefined { #endif struct ssl_general_config general_ssl; /* general user defined SSL stuff */ int dns_cache_timeout; /* DNS cache timeout (seconds) */ - long buffer_size; /* size of receive buffer to use */ + unsigned int buffer_size; /* size of receive buffer to use */ unsigned int upload_buffer_size; /* size of upload buffer to use, keep it >= CURL_MAX_WRITE_SIZE */ void *private_data; /* application-private data */ diff --git a/lib/vtls/vtls.c b/lib/vtls/vtls.c index faa1b51417..970ec92f92 100644 --- a/lib/vtls/vtls.c +++ b/lib/vtls/vtls.c @@ -899,7 +899,7 @@ char *Curl_ssl_snihost(struct Curl_easy *data, const char *host, size_t *olen) size_t len = strlen(host); if(len && (host[len-1] == '.')) len--; - if((long)len >= data->set.buffer_size) + if(len >= data->set.buffer_size) return NULL; Curl_strntolower(data->state.buffer, host, len);