mirror of
https://github.com/curl/curl.git
synced 2026-07-30 16:18:02 +03:00
lib: accept larger input to md5/hmac/sha256/sha512 functions
Avoid unchecked data conversions from size_t to unsigned int. Reported-by: James Fuller Closes #21174
This commit is contained in:
parent
1570091f10
commit
dd7fcd581f
7 changed files with 41 additions and 20 deletions
|
|
@ -540,14 +540,19 @@ const struct MD5_params Curl_DIGEST_MD5 = {
|
|||
* Returns CURLE_OK on success.
|
||||
*/
|
||||
CURLcode Curl_md5it(unsigned char *output,
|
||||
const unsigned char *input, const size_t len)
|
||||
const unsigned char *input, size_t len)
|
||||
{
|
||||
CURLcode result;
|
||||
my_md5_ctx ctx;
|
||||
|
||||
result = my_md5_init(&ctx);
|
||||
if(!result) {
|
||||
my_md5_update(&ctx, input, curlx_uztoui(len));
|
||||
do {
|
||||
unsigned int ilen = (unsigned int) CURLMIN(len, UINT_MAX);
|
||||
my_md5_update(&ctx, input, ilen);
|
||||
input += ilen;
|
||||
len -= len;
|
||||
} while(len);
|
||||
my_md5_final(output, &ctx);
|
||||
}
|
||||
return result;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue