Fenrir: Resource Leaks#591
Conversation
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #591
Scan targets checked: wolfssl-examples-bugs, wolfssl-examples-src
Findings: 2
2 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Findings are non-blocking.
… F-2102 F-2103 F-2896 F-2907 F-2912 F-3226 F-3474 F-3475 F-3476 F-4128 F-4129 F-4602: fix socket, file descriptor, file handle, and key leaks in BLE, custom IO, can-bus, PKCS7, TLS, and PQ examples
52c9ae0 to
fb4bde8
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #591
Scan targets checked: wolfssl-examples-bugs, wolfssl-examples-src
Findings: 3
3 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Findings are non-blocking.
fb4bde8 to
4070dd8
Compare
4070dd8 to
a6c93cb
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #591
Scan targets checked: wolfssl-examples-bugs, wolfssl-examples-src
Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Findings are non-blocking.
81d7c99 to
8e47b06
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #591
Scan targets checked: wolfssl-examples-bugs, wolfssl-examples-src
Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Findings are non-blocking.
… F-3696 F-3892 F-3893 F-3894 F-3896 F-4126 F-4609 F-6291: fix memory leaks, resource release, and private-key zeroization in crypto, ECC, OCSP, DTLS, certgen, PUF, and optimizer examples
8e47b06 to
7999d1f
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #591
Scan targets checked: wolfssl-examples-bugs, wolfssl-examples-src
Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Findings are non-blocking.
|
|
||
| ret = wc_InitRsaKey_ex(&rsaPriv, NULL, INVALID_DEVID); | ||
| if (ret != 0) { | ||
| free(der); |
There was a problem hiding this comment.
🟠 [Medium] Private key DER freed without zeroization in myCryptoCb error paths · Missing error handling
der is loaded from myCtx->keyFilePriv (private key file) and freed with bare free(der) — without wc_ForceZero — on the two new wc_InitRsaKey_ex and wc_ecc_init_ex failure paths introduced by this PR (lines 248 and 311), leaving private key bytes in freed heap memory.
Fix: Replace free(der) with wc_ForceZero(der, derSz); free(der); at both new error-path exits (RSA line 248, ECC line 311).
Fixes leaked sockets, file descriptors, file handles, and heap allocations on error paths throughout the examples, and zeroizes private-key material before freeing it instead of leaving it in freed memory. Also updated to using wolfSSL macros (memcpy vs XMEMCPY) and improved some examples to better comply with coding standards for cross-platform compatibility.