lib: accept larger input to md5/hmac/sha256/sha512 functions#21174
lib: accept larger input to md5/hmac/sha256/sha512 functions#21174
Conversation
Avoid unchecked data conversions from size_t to unsigned int. Reported-by: James Fuller
There was a problem hiding this comment.
Pull request overview
This PR aims to make internal digest/HMAC helpers safely handle inputs larger than what underlying hash update APIs accept, avoiding unchecked size_t → unsigned int conversions.
Changes:
- Update MD5/SHA256/HMAC “one-shot” helpers to accept
size_tlengths and process input in chunks. - Adjust HMAC update API to return
voidand add a guard for oversized HMAC keys. - Chunk wolfSSL SHA-512/256 update calls to avoid truncating large input sizes.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/sha256.c | Switches Curl_sha256it() to chunk input rather than casting size_t to unsigned int. |
| lib/md5.c | Switches Curl_md5it() to chunk input rather than casting size_t to unsigned int. |
| lib/hmac.c | Updates HMAC update signature and chunks Curl_hmacit() input; adds keylen > UINT_MAX guard. |
| lib/curl_sha512_256.c | Chunks wolfSSL SHA-512/256 update calls to avoid truncation for large size_t lengths. |
| lib/curl_hmac.h | Updates prototypes to match HMAC API changes (Curl_HMAC_update return type; Curl_hmacit datalen type). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Good bot. That was simply a too naive fix... |
|
augment review |
🤖 Augment PR SummarySummary: This PR hardens the internal MD5/HMAC/SHA256/SHA512-256 helpers to safely accept inputs larger than what fits in an Changes:
Technical Notes: The new loops repeatedly feed 🤖 Was this summary useful? React with 👍 or 👎 |
Avoid unchecked data conversions from size_t to unsigned int.
Reported-by: James Fuller