mirror of
https://github.com/curl/curl.git
synced 2026-04-14 22:01:41 +03:00
hmac: return error if init fails
They can actually happen in OOM situtations. Reported-by: Philippe Antoine Closes #18008
This commit is contained in:
parent
24f8442e6a
commit
2714486d89
1 changed files with 5 additions and 3 deletions
|
|
@ -73,7 +73,8 @@ Curl_HMAC_init(const struct HMAC_params *hashparams,
|
|||
|
||||
/* If the key is too long, replace it by its hash digest. */
|
||||
if(keylen > hashparams->maxkeylen) {
|
||||
hashparams->hinit(ctxt->hashctxt1);
|
||||
if(hashparams->hinit(ctxt->hashctxt1))
|
||||
return NULL;
|
||||
hashparams->hupdate(ctxt->hashctxt1, key, keylen);
|
||||
hkey = (unsigned char *) ctxt->hashctxt2 + hashparams->ctxtsize;
|
||||
hashparams->hfinal(hkey, ctxt->hashctxt1);
|
||||
|
|
@ -82,8 +83,9 @@ Curl_HMAC_init(const struct HMAC_params *hashparams,
|
|||
}
|
||||
|
||||
/* Prime the two hash contexts with the modified key. */
|
||||
hashparams->hinit(ctxt->hashctxt1);
|
||||
hashparams->hinit(ctxt->hashctxt2);
|
||||
if(hashparams->hinit(ctxt->hashctxt1) ||
|
||||
hashparams->hinit(ctxt->hashctxt2))
|
||||
return NULL;
|
||||
|
||||
for(i = 0; i < keylen; i++) {
|
||||
b = (unsigned char)(*key ^ hmac_ipad);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue