mirror of
https://github.com/curl/curl.git
synced 2026-07-25 14:37:17 +03:00
lib: eliminate size_t casts
Add new functions in `curlx/warnless.h` for controlled type conversions: * curlx_uitouz, convert unsigned into to size_t (should always work) * curlx_uztoso, convert size_t to curl_off_t, capping at CURL_OFF_T_MAX * curlx_sztouz, convert ssize_t to size_t, return TRUE when ok * curlx_sotouz_range, convert curl_off_t to size_t interval, capping values to interval bounds Remove some unnecesary casts, convert some internal recv functions to the "return result, have size_t* arg" pattern. Closes #19495
This commit is contained in:
parent
78a610cb83
commit
cb2bcb681f
13 changed files with 170 additions and 156 deletions
|
|
@ -2222,9 +2222,11 @@ static CURLcode set_reader(struct Curl_easy *data, Curl_HttpReq httpreq)
|
|||
result = Curl_creader_set_null(data);
|
||||
}
|
||||
else if(data->set.postfields) {
|
||||
if(postsize > 0)
|
||||
result = Curl_creader_set_buf(data, data->set.postfields,
|
||||
(size_t)postsize);
|
||||
size_t plen = curlx_sotouz_range(postsize, 0, SIZE_MAX);
|
||||
if(plen == SIZE_MAX)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
else if(plen)
|
||||
result = Curl_creader_set_buf(data, data->set.postfields, plen);
|
||||
else
|
||||
result = Curl_creader_set_null(data);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue