Repository navigation
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the bounds-check ordering and ESP32 cleanup-limit changes.
No open issues 🎉
What changed in this PR
This PR fixes bounds-check ordering in the ESP32 port and IoT-Safe example, preventing reads past numeric and output buffers.
Changes:
- Check array and buffer bounds before reading elements in three loops.
- Bound ESP32 math cleanup by the number’s capacity rather than a fixed 128-digit limit.
- Reorder the ESP32 string-loop checks defensively; terminated inputs were already safe.
| File | Description |
|---|---|
wolfcrypt/src/port/Espressif/esp32_util.c |
Check the string-copy limit before reading characters. |
wolfcrypt/src/port/Espressif/esp32_mp.c |
Use the digit capacity and check bounds before reading during cleanup. |
IDE/iotsafe/devices.c |
Check the output-buffer boundary before dereferencing the pointer. |
Review effort: Balanced
|
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #12045
Scan targets checked: wolfcrypt-port-bugs
Not reviewed (no scan target covers them): IDE/iotsafe/devices.c
Coverage: 2 of 2 in-scope changed file(s) opened by the reviewer
Fenrir result: Approved ✅
No new issues found in the changed files.
Advisory only — this automated result does not count as a GitHub approval.
Review tier: Max
Description
Three loops read an element before checking that its index was in range:
esp_clean_result()in the ESP32 math port: read one digit past the array, and was bounded by a fixed 128 rather than the number's allocated size. It now usesZ->sizewith SP math andFP_SIZEwith fast math, and checks the bound first.show_macro()in the ESP32 utilities: checked the bound last. No out-of-bounds access was possible here, as the input is a terminated string._write()in the IoT-Safe example: read one byte past a buffer with no terminator.Fixes ZD22754. Reported by Md. Raisul Islam Mobin (https://mobin.tech | @mobin2021).
Testing
The reporter's harness under AddressSanitizer reports each read with the old conditions and none with the new ones. Not built for ESP32 or the IoT-Safe target: no toolchain for either was available.
Checklist